i am using postgrest exception in function 'public.main_function'. in exception 'others', i also use sub functions to save my log data.
but my sub function 'public.something_went_wrong_log_creation' might be error sometimes.
how can i add exception (nested exception) in exception 'others' below?
CREATE OR REPLACE FUNCTION public.main_function(request json)
RETURNS integer AS
$BODY$
BEGIN
-- statement 1
-- statement 2
-- statement 3
RETURN 1;
EXCEPTION
-- SOMETHING WENT WRONG
WHEN others
THEN
-- LOG SOMETHING WENT WRONG
PERFORM public.something_went_wrong_log_creation();
RETURN 0;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
CREATE OR REPLACE FUNCTION public.something_went_wrong_log_creation()
RETURNS integer AS
$BODY$
BEGIN
-- statement 1
-- statement 2
-- statement 3
RETURN 1;
EXCEPTION
-- SOMETHING WENT WRONG
WHEN others
THEN
RETURN 0;
END;
$BODY$
LANGUAGE plpgsql VOLATILE