== Why is this an issue? Since Oracle 10g, ``++DBMS_UTILITY.FORMAT_ERROR_BACKTRACE++`` is available to get an exception's stack trace, i.e. files and lines that lead up to the exception. When combined with ``++DBMS_UTILITY.FORMAT_ERROR_STACK++``, which contains the exception error code and message, developers are able quickly identify defects. This rule verifies that whenever either is used in an exception handler, the other is used as well. === Noncompliant code example [source,sql] ---- BEGIN RAISE_APPLICATION_ERROR(-20000, 'This is an error example'); EXCEPTION WHEN OTHERS THEN -- Noncompliant; only FORMAT_ERROR_STACK is used DBMS_OUTPUT.PUT(DBMS_UTILITY.FORMAT_ERROR_STACK); -- "ORA-20000: This is an error example" DBMS_OUTPUT.PUT_LINE(''); END; / ---- === Compliant solution [source,sql] ---- BEGIN RAISE_APPLICATION_ERROR(-20000, 'This is an error example'); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT(DBMS_UTILITY.FORMAT_ERROR_STACK); -- "ORA-20000: This is an error example" DBMS_OUTPUT.PUT(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE); -- "ORA-06512: at line 2" DBMS_OUTPUT.PUT_LINE(''); END; / ---- ifdef::env-github,rspecator-view[] ''' == Implementation Specification (visible only on this page) === Message Use both "FORMAT_ERROR_STACK" and "FORMAT_ERROR_BACKTRACE" in this exception handler. ''' == Comments And Links (visible only on this page) === on 23 May 2013, 14:05:21 Dinesh Bolkensteyn wrote: http://rajeshwaranbtech.blogspot.fr/2010/05/dbmsutilityformaterrorbacktrace-10g-new.html endif::env-github,rspecator-view[]