I\'m using TypeScript for a reasonably large project, and am wondering what the standard is for the use of Error
s. For example, say I hand an index out of bounds ex
Simple solution to emit and show message by Exception.
try {
throw new TypeError("Error message");
}
catch (e){
console.log((e).message);//conversion to Error type
}
Above is not a solution if we don't know what kind of error can be emitted from the block. In such cases type guards should be used and proper handling for proper error should be done - take a look on @Moriarty answer.