When deciding if to ignore, handle of re-throw errors in a Try Catch
structure, what is the best way to uniquely identify the exact error?
I can't find any standard error number, do I have to parse the name
and message
properties?
EDIT: In the example below, I want to check if the error is due to the lack of a property on listEvent who's key is the value of evnt.type. If this is the source of the error, I want to ignore it, otherwise I want to re-throw it to let it bubble up.
The only way I can think of is sort of duck-typing the error like this...
try{
listEvent[evnt.type](procedure)
}catch(error){
if (error.message.match(evnt.type)) {
console.log(error.name + ' ' + error.message + ' - ignored')
} else {
throw error
}
}
Error
subclass structures)