Fancy error reporting with miette

Поділитися
Вставка
  • Опубліковано 8 вер 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

КОМЕНТАРІ • 11

  • @felixst-gelais6722
    @felixst-gelais6722 Рік тому +15

    fun fact: "miette" means "crumb" in french! so the lib is comparing error reporting with "following bread crumbs", which i think is pretty neat

  • @whoisryosuke
    @whoisryosuke Рік тому +1

    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... 🤔

    • @chrisbiscardi
      @chrisbiscardi  Рік тому +4

      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.

  • @Siniverisyys
    @Siniverisyys Рік тому

    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 ;-)

  • @azzamsya
    @azzamsya Рік тому

    Thank you so much for this tutorial!

  • @Yotanido
    @Yotanido Рік тому

    For fancy parse errors, Ariadne is also very nice

    • @chrisbiscardi
      @chrisbiscardi  Рік тому

      ariadne is listed as inspiration in miette's readme too!

  • @katopz
    @katopz Рік тому

    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. 🤔

    • @iippari7
      @iippari7 Рік тому +1

      Did you remember to enable the `fancy` feature? I've never used miette, but that sounds like it could be what's going wrong.

    • @underhilloverhill
      @underhilloverhill Рік тому +2

      could be the terminal/font config

    • @magnusmarkling
      @magnusmarkling Рік тому +1

      I get the smooth underline when running a simple example (with "fancy" enabled) in both Terminal and iTerm2 apps on MacOS. Nothing else required.