DEV Community

Discussion on: Switch-cased Error Handling in JavaScript

Collapse
 
jonrandy profile image
Jon Randy πŸŽ–οΈ

I use it all the time. You can also use it to test the conditions of anything you like. Often makes for more readable code

Collapse
 
zirkelc profile image
Chris Cook

I find it difficult to apply such patterns (especially e instaceof <class>) because in JS it's not obvious what the errors that you have to catch and handle could be. In other language such as C#, Java, etc. the thows signature gives you this information, but in JS you have to hope it's documented somewhere.