Fancy error reporting with miette
Вставка
- Опубліковано 27 гру 2024
- Learn Rust at www.rustadvent...
Fancy error reporting with miette and thiserror.
GitHub Repo: github.com/rus...
First color CLI video: • Generating colors with...
Twitter: / rustadventure
Twitter: / chrisbiscardi
fun fact: "miette" means "crumb" in french! so the lib is comparing error reporting with "following bread crumbs", which i think is pretty neat
I felt like that I didn't have the time or energy to take on miette's fancy error handling, but you explained it so well it seems pretty easy now. Really looking forward to the `wrap_err` feature too. Probably not just helpful to the user - helpful to the developer too ;-)
Great way to add structured error output to a project. I like how clean everything looks implemented.
Maybe a little confusing with miette using `Result`? Maybe `MResult` might be better for them to avoid confusion... 🤔
type aliasing Result to specialize it to the type in the library crate it's being used in is a fairly common approach. serde_json has a Result, reqwest has one too, and even the standard library uses on in std::io::Result.
You can always swap `use miette::Result` instead with a miette::Result in the type signature to be more clear if you want to.
For fancy parse errors, Ariadne is also very nice
ariadne is listed as inspiration in miette's readme too!
Thank you so much for this tutorial!
How can I have smooth line pointer and underline error print out like that?
All I have here is an ascii ^^^^^^^^^^^^^^^^^^^^^^^ like this when error. 🤔
Did you remember to enable the `fancy` feature? I've never used miette, but that sounds like it could be what's going wrong.
could be the terminal/font config
I get the smooth underline when running a simple example (with "fancy" enabled) in both Terminal and iTerm2 apps on MacOS. Nothing else required.