DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
19.3k stars 735 forks source link

Improve error handling in `dx fmt` #2240

Open matthunz opened 2 months ago

matthunz commented 2 months ago

Feature Request

Currently when dx fmt fails, I usually see a panic with little indication to what's causing the error. While formatting is being worked out I think it'd be helpful to see a line number and maybe a section of the code causing the error, so we can all help narrow down formatting bugs.

Implement Suggestion

Replace .unwrap() by returning a custom error type that wraps anyhow::Error. Maybe something like

pub struct Error {
  span: Option<Span>,
  cause: anyhow::Error
}