Exception declaration is handled by the raise function.
This is a deprecated version of the SnowConvert documentation, please visit the official site HERE.
Severity
Low
Description
Exceptions can be defined in both languages, Oracle and Snowflake, but the RAISE function is designed to do declaration, assignment, and throw the error. This is why the Exception declaration is commented out and the warning is displayed.
Example Code
Input Code:
CREATE OR REPLACE PROCEDURE EXCEPTION_DECLARATION_SAMPLE AUTHID DEFINER IS NEW_EXCEPTION EXCEPTION; PRAGMA EXCEPTION_INIT(NEW_EXCEPTION, -63);BEGIN IF true THEN RAISE NEW_EXCEPTION; END IF;EXCEPTION WHEN NEW_EXCEPTION THEN--Handle ExceptionsEND;/
Output Code:
--Basic example with raiseCREATE OR REPLACE PROCEDURE PUBLIC.EXCEPTION_DECLARATION_SAMPLE ()RETURNS STRINGLANGUAGE JAVASCRIPTEXECUTE AS CALLERAS$$//Helpers declaration var RAISE =function (code,name,message) { var error = new Error(message); Object.assign(error,{ code : code,name : name,message : message }) SQLCODE = error.code SQLERRM =`${error.code}: ${message}`throw error; }; {/*** MSC-WARNING - MSCEWI3052 - EXCEPTION DECLARATION IS HANDLED BY RAISE FUNCTION ***//* NEW_EXCEPTION EXCEPTION*/ ;/*** MSC-WARNING - MSCEWI3051 - PRAGMA EXCEPTION_INIT IS NOT SUPPORTED. ERROR CODE IS ASSIGNED IN RAISE CALL ***//* PRAGMA EXCEPTION_INIT(NEW_EXCEPTION, -63)*/ ;try {if (true) { RAISE(63,"NEW_EXCEPTION","NEW_EXCEPTION"); } } catch(error) { switch(error.name) {case`NEW_EXCEPTION`: {//Handle Exceptionbreak; }default: {throw error;break; } } } }$$;