Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 353
Nathan Bellowe Avatar asked Oct 16 '22 13:10

Nathan Bellowe


People also ask

How do you correct errors in a sentence?

There are two main ways to repair sentence fragments. Expand the fragments into sentences, supplying the missing elements like subjects, verbs, and clauses. Incorrect: Confusing and distracting to readers. Correct: Sentence fragments are confusing and distracting to readers.

Is it grammar errors or grammatical errors?

"Grammar error" is a compound noun; "grammatical error" is a noun modified by an adjective. Both are in use, but the latter is preferred in material that can be searched online. Highly active question.

What are errors in a sentence?

A type of sentence error known as sentence fragment is a group of words that used together does not form a complete sentence; it is just a part of a sentence that doesn't express a complete idea.


1 Answers

Someone posted this link to the MDN in a comment, and I think it was very helpful. It describes things like ErrorTypes very thoroughly.

EvalError --- Creates an instance representing an error that occurs regarding the global function eval().

InternalError --- Creates an instance representing an error that occurs when an internal error in the JavaScript engine is thrown. E.g. "too much recursion".

RangeError --- Creates an instance representing an error that occurs when a numeric variable or parameter is outside of its valid range.

ReferenceError --- Creates an instance representing an error that occurs when de-referencing an invalid reference.

SyntaxError --- Creates an instance representing a syntax error that occurs while parsing code in eval().

TypeError --- Creates an instance representing an error that occurs when a variable or parameter is not of a valid type.

URIError --- Creates an instance representing an error that occurs when encodeURI() or decodeURI() are passed invalid parameters.

like image 149
Nathan Bellowe Avatar answered Oct 27 '22 02:10

Nathan Bellowe