Skip to content

Files

Latest commit

 

History

History
30 lines (23 loc) · 570 Bytes

avoid_catching_errors.md

File metadata and controls

30 lines (23 loc) · 570 Bytes

Pattern: Use of explicit Error catch

Issue: -

Description

Errors differ from Exceptions in that Errors can be analyzed and prevented prior to runtime. It should almost never be necessary to catch an error at runtime.

Example of incorrect code:

try {
 somethingRisky();
} on Error catch(e) {
 doSomething(e);
}

Example of correct code:

try {
 somethingRisky();
} on Exception catch(e) {
 doSomething(e);
}

Further Reading