To Nha Notes | Feb. 10, 2023, 8:29 a.m.
declare
my_exception exception (-20001, 'Sample message');
begin
raise my_exception;
exception
when statement_error then
return object_construct('Error type', 'STATEMENT_ERROR',
'SQLCODE', sqlcode,
'SQLERRM', sqlerrm,
'SQLSTATE', sqlstate);
when expression_error then
return object_construct('Error type', 'EXPRESSION_ERROR',
'SQLCODE', sqlcode,
'SQLERRM', sqlerrm,
'SQLSTATE', sqlstate);
when other then
return object_construct('Error type', 'Other error',
'SQLCODE', sqlcode,
'SQLERRM', sqlerrm,
'SQLSTATE', sqlstate);
end;
https://docs.snowflake.com/en/developer-guide/snowflake-scripting/blocks.html
https://docs.snowflake.com/en/sql-reference/snowflake-scripting/exception.html
https://docs.snowflake.com/en/sql-reference/sql/create-task.html