Pattern: Use of explicit Error
catch
Issue: -
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);
}