syn-rsx icon indicating copy to clipboard operation
syn-rsx copied to clipboard

Improve error handling

Open stoically opened this issue 5 years ago • 3 comments

Currently syn-rsx hardcodes error strings, which might not fit into what consumers expect. Also some errors lack context information to allow consumers to properly show errors. It'd probably be more elegant to instead have a custom Error with sensible context information (some sort of Enum) and an useful Span, maybe if possible with some default error strings as convenience fallback.

stoically avatar Jan 05 '21 00:01 stoically

https://docs.rs/error-stack in combination with thiserror looks promising for this task.

stoically avatar Oct 22 '22 16:10 stoically

If possible it'd be nice to attach the Node to the error-stack report.

stoically avatar Oct 26 '22 17:10 stoically

syn always expects a syn::Error to be returned from a parser struct / closure. So currently I don't see a way to expose a custom error to consumers. Only workaround seems to be allowing to set custom error display strings via configuration.

Upstream issue: https://github.com/dtolnay/syn/issues/1239

stoically avatar Oct 31 '22 14:10 stoically