js-formatter icon indicating copy to clipboard operation
js-formatter copied to clipboard

Include a custom error class to differentiate unexpected errors

Open tmcw opened this issue 1 year ago • 1 comments

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.

tmcw avatar Oct 30 '23 16:10 tmcw

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.

dsherret avatar Oct 30 '23 16:10 dsherret