Created
March 27, 2015 20:30
-
-
Save ssube/a99f78a36b2e353ae41d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyError extends Error { | |
constructor() { | |
super(); | |
} | |
} | |
class YourError extends MyError { | |
constructor() { | |
super(); | |
} | |
} | |
try { | |
throw new MyError(); | |
} catch (e) { | |
switch (e.constructor) { | |
case YourError: console.log("Was instance of your error!"); break; | |
case MyError: console.log("Was instance of my error!"); break; | |
default: console.log("Unknown error type!"); break; | |
} | |
} | |
try { | |
throw new YourError(); | |
} catch (e) { | |
switch (e.constructor) { | |
case MyError: console.log("Was instance of my error!"); break; | |
case YourError: console.log("Was instance of your error!"); break; | |
default: console.log("Unknown error type!"); break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment