Shadowing all exceptions with NULL statements indicates that no error handling has been done for a given block of code. This is a common bad-practice and only the non-relevant exceptions should be ignored (and a comment is welcome in such cases).


== Noncompliant Code Example

----
BEGIN 
  SELECT value 
    INTO :hits 
    FROM hitCounter 
   WHERE pageIn = 'Sample'; 
EXCEPTION                    -- Noncompliant
  WHEN OTHERS THEN 
    NULL; 
END; 

BEGIN 
  SELECT value 
    INTO :hits 
    FROM hitCounter 
   WHERE pageIn = 'Sample'; 
EXCEPTION                    -- Noncompliant
  WHEN TOO_MANY_ROWS THEN
    NULL;
  WHEN OTHERS THEN 
    NULL; 
END; 
----


== Compliant Solution

----
BEGIN 
  SELECT value 
    INTO :hits 
    FROM hitCounter 
   WHERE pageIn = 'Sample'; 
EXCEPTION                    -- Compliant
  WHEN NO_DATA_FOUND THEN
    hits := 0;
  WHEN TOO_MANY_ROWS THEN
    DBMS_OUTPUT.PUT_LINE('Error: too many entries for Sample');
  WHEN OTHERS THEN 
    -- Cannot do more in this case
    NULL; 
END; 
----


== See

* http://cwe.mitre.org/data/definitions/391.html[MITRE, CWE-391] - Unchecked Error Condition


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
