I\'m using TypeScript for a reasonably large project, and am wondering what the standard is for the use of Errors. For example, say I hand an index out of bounds ex
The convention for out of range in JavaScript is using RangeError. To check the type use if / else + instanceof starting at the most specific to the most generic
try {
throw new RangeError();
}
catch (e){
if (e instanceof RangeError){
console.log('out of range');
} else {
throw;
}
}