org.sonar.l10n.plsqlopen.rules.plsql.UnhandledUserDefinedException.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zpa-checks Show documentation
Show all versions of zpa-checks Show documentation
Z PL/SQL Analyzer :: Checks
The newest version!
When a custom exception is declared and not handled in the code, raising this exception will cause the error
"ORA-06510: PL/SQL: unhandled user-defined exception" in the database or the error "User-defined exception" in
Oracle Forms.
It is a good practice to handle custom exceptions.
Noncompliant Code Example
DECLARE
my_exception EXCEPTION;
BEGIN
...
RAISE my_exception; -- this will cause an "user-defined exception"
END;
Compliant Solution
DECLARE
my_exception EXCEPTION;
BEGIN
...
RAISE my_exception;
EXCEPTION
WHEN my_exception THEN
...
END;
This check will also trigger a violation if the exception is handled by a OTHERS handler and it has a reference to SQLERRM.
In this case, the SQLERRM will return "User-defined exception", which is not very useful.
DECLARE
my_exception EXCEPTION;
BEGIN
...
RAISE my_exception;
EXCEPTION
WHEN OTHERS THEN
log(SQLERRM);
END;