33 lines
787 B
Plaintext
33 lines
787 B
Plaintext
An ``++EXCEPTION WHEN ... THEN++`` clause that only rethrows the caught exception has the same effect as omitting the ``++EXCEPTION++`` clause altogether and letting it bubble up automatically, but with more code and the additional detriment of leaving maintainers scratching their heads.
|
|
|
|
|
|
Such clauses should either be eliminated or populated with the appropriate logic.
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
BEGIN
|
|
SELECT 1/0;
|
|
EXCEPTION
|
|
WHEN ZERO_DIVIDE THEN
|
|
RAISE; -- Noncompliant
|
|
WHEN OTHERS THEN
|
|
RAISE; -- Noncompliant
|
|
END;
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
BEGIN
|
|
SELECT 1/0;
|
|
EXCEPTION
|
|
WHEN ZERO_DIVIDE THEN -- Compliant: handles 'division by zero' error
|
|
-- do something to manage the division by zero
|
|
COMMIT;
|
|
|
|
WHEN OTHERS THEN
|
|
ROLLBACK;
|
|
END;
|
|
----
|