The PL/SQL compiler warnings have been enhanced in 11.2.0.1 and up to include a warning for the dreaded “when others then null” exception handler. Actually, the warning is raised any time an “others” is handled (even if it is logged somewhere), and not re-raised.
See below for an example.
SQL> show parameter warn
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
license_sessions_warning integer 0
plsql_warnings string DISABLE:ALL
SQL> alter session set plsql_warnings = 'ENABLE:ALL';
Session altered.
SQL> create or replace procedure foo is
2 l number;
3 begin
4 begin
5 l := 'a';
6 exception
7 when others then
8 null;
9 end;
10 null;
11 exception
12 when others then
13 dbms_output.put_line(sqlerrm);
14 raise;
15 end;
16 /
SP2-0804: Procedure created with compilation warnings
SQL> show err
Errors for PROCEDURE FOO:
LINE/COL ERROR
-------- -----------------------------------------------------------------
1/1 PLW-05018: unit FOO omitted optional AUTHID clause; default value
DEFINER used
5/5 PLW-07206: analysis suggests that the assignment to 'L' may be
unnecessary
7/10 PLW-06009: procedure "FOO" OTHERS handler does not end in RAISE
or RAISE_APPLICATION_ERROR
SQL>
The risk in not re-raising the exception is that the executing call never knows an exception occurred in that block. When it comes to an “others” exception, that is simply too much risk in an application, since by definition, you have no idea what happened. You should know what exceptions to expect, and handle them. Anything else means you didn’t think of it, so you don’t really have a good reason to just ignore it (since you didn’t even think of it in the first place).