G-5070
🆓Avoid using Oracle predefined exceptions.
Reason
You have raised an exception whose name was defined by Oracle. While it is possible that you have a good reason for "using" one of Oracle's predefined exceptions, you should make sure that you would not be better off declaring your own exception and raising that instead.
If you decide to change the exception you are using, you should apply the same consideration to your own exceptions. Specifically, do not "re-use" exceptions. You should define a separate exception for each error condition, rather than use the same exception for different circumstances.
Being as specific as possible with the errors raised will allow developers to check for, and handle, the different kinds of errors the code might produce.
Example
Non-Compliant Example
begin raise no_data_found; end; /
Issues
Line | Column | Message |
---|---|---|
2 | 10 |
★★★★★
Compliant Solution -
declare e_my_exception exception; begin raise e_my_exception; end; /
Parameters
Use parameters to customize the rule to your needs.
Parameter | Description | Default Value |
---|---|---|
PredefinedExceptionNames | Comma separated List of predefined exception names. | access_into_null, case_not_found,collection_is_null, cursor_already_open, dup_val_on_index, invalid_cursor, invalid_number, login_denied, no_data_found, no_data_needed, not_logged_on, program_error, rowtype_mismatch, self_is_null, storage_error, subscript_beyond_count, subscript_outside_limit, sys_invalid_rowid, timeout_on_resource, too_many_rows, value_error, zero_divide |
References
- same as Trivadis G-5070