rspec/rules/S2737/plsql/rule.adoc

40 lines
947 B
Plaintext
Raw Normal View History

2021-01-27 13:42:22 +01:00
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.
2020-06-30 12:48:07 +02:00
2021-02-02 15:02:10 +01:00
2020-06-30 12:48:07 +02:00
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;
----
ifdef::env-github,rspecator-view[]
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]