How would you implement different types of errors so that you can catch specific ones and let others bubble up ...?
One way to achieve this is to change the prototype of the Error
object:
Error.prototype.sender = ""; function throwSpecificError() { var e = new Error(); e.sender = "specific"; throw e; }
Error specific error:
try { throwSpecificError(); } catch (e) { if (e.sender !== "specific") throw e;
Do you have any alternatives?
javascript error-handling
roosteronacid Sep 16 '09 at 15:00 2009-09-16 15:00
source share