Skip to content

Files

Latest commit

 

History

History
32 lines (25 loc) · 569 Bytes

avoid_catches_without_on_clauses.md

File metadata and controls

32 lines (25 loc) · 569 Bytes

Pattern: Use of catch without on

Issue: -

Description

Using catch clauses without on clauses make your code prone to encountering unexpected errors that won't be thrown (and thus will go unnoticed).

Example of incorrect code:

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

Example of correct code:

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

Further Reading