Proper use of errors

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 exception in Java:

throw new IndexOutOfBoundsException();

Would the equivalent statement in TypeScript be:

throw new Error("Index Out of Bounds");

What other ways could I accomplish this? What is the accepted standard?

4 Answers
4

Leave a Comment