OracleCommand throws exception which is handed within package method

198 Views Asked by At

I am having a strange issue where I am calling an Oracle package method call using Dapper's ExecuteAsync extension:

var rowsAffected = await Connection.ExecuteAsync(command, parameters, commandType: CommandType.StoredProcedure);

Initially I posted this in Dapper GitHub project but after inspecting the code of the extension method, it is rather obvious that the exception is thrown by the OracleCommand and has nothing to do with Dapper itself, so I don't expect any feedback there, maybe some taunting which I hope it will not be materialised to a respective reply :-). This Oracle package method internally has an exception handling mechanism which handles all exceptions and returns any errors in an out parameter called p_err_msg:

EXCEPTION

WHEN OTHERS THEN
v_err_msg := SQLERRM;
v_sql_code := SQLCODE;
v_err_msg := v_err_msg||' '||primaky_key||' '||dbms_utility.format_error_backtrace;
p_err_msg := v_err_msg;
DBMS_OUTPUT.PUT_LINE(p_err_msg);
END;

Calling the package method from any Oracle IDE (SQL Developer, TOAD etc) demonstrates the expected behaviour, not throwing an exception but returns the error message in the out variable. Calling OracleConnection.ExecuteAsync for the same method with the same parameters results to the exception, which is handled in the package method, being thrown to the client. Any idea why this happens and how it can be avoided. It is causing an issue because we want to make sure that exception is only thrown in any case that we fail to execute the method (connectivity issues) but not when an error internal to the package method is thrown.

0

There are 0 best solutions below