10
As far as I know, Javascript has no error typing.
In C# and Java, it is possible to do things like:
try {
/* .. snip .. */
} catch (FooException foo) {
/* .. snip .. */
} catch (BarException bar) {
/* .. snip .. */
} catch (NotEnoughCoffeException nec) {
/* .. snip .. */
} /* etc. */
And so we give a different error treatment for each type of exception.
In javascript, the best we have is:
try {
/* .. snip .. */
} catch (couldBeAnything) {
/* dize-me com quem erras e te direi quem és */
}
And what’s worse, it doesn’t even have duck typing to help at this time.
When we have some Javascript code that can fail in several different ways... Is there any design pattern, any methodology to identify what happened? Some way to insert an error code in the exception, for example?