dprint / js-formatter

JS formatter for dprint Wasm plugins.
MIT License
31 stars 5 forks source link

Include a custom error class to differentiate unexpected errors #8

Open tmcw opened 10 months ago

tmcw commented 10 months ago

dprint will throw an error if the input code has bad syntax, but there are presumably other errors that can be thrown by the module too. It'd be nice if there was a custom Error subclass that was used & exported so that downstream applications can decide which errors to log and send to error tracking systems or show to users, and which errors are expected and just the result of bad syntax.

dsherret commented 10 months ago

dprint will throw an error if the input code has bad syntax, but there are presumably other errors that can be thrown by the module too.

I think right now the only errors it surfaces are ones to show to users (bad syntax). Maybe I'm misremembering something, but I think just forwarding all errors to the user should be fine.