Rain Paharia
๐ค SpeakerAppearances Over Time
Podcast Appearances
If you're familiar, one of the things that's really interesting about Rust is that Rust C has great error messages. And I think that's one of the reasons that all of us feel pretty good about Rust, right? Is that fair to say?
And with the error messages, I think one of the things that's really nice is there's this lovely syntax highlighting where it'll show you the exact things that were wrong and it will give you a suggestion of what to do instead and all of those things. Amazing. Yeah, it's so good. And so there's actually a few crates that do that.
And with the error messages, I think one of the things that's really nice is there's this lovely syntax highlighting where it'll show you the exact things that were wrong and it will give you a suggestion of what to do instead and all of those things. Amazing. Yeah, it's so good. And so there's actually a few crates that do that.
So the Rust C's own error thing is extracted out into a crate that I don't remember the name of off the top of my head. Then there's another crate called ColdSpan, but Miette also captures all of that. And Miette actually, one of the things it can do is it can store a list of errors.
So the Rust C's own error thing is extracted out into a crate that I don't remember the name of off the top of my head. Then there's another crate called ColdSpan, but Miette also captures all of that. And Miette actually, one of the things it can do is it can store a list of errors.
So what you can do is, and I have used this pattern in some places, is that you actually store a list of errors and then you have Miette report that with, so you can provide the source code that those errors associated with and the byte offset. And so you kind of provide that source code and then Viet will kind of render that in a nice way.
So what you can do is, and I have used this pattern in some places, is that you actually store a list of errors and then you have Miette report that with, so you can provide the source code that those errors associated with and the byte offset. And so you kind of provide that source code and then Viet will kind of render that in a nice way.
So it's, I think that kind of style of like high quality error reporting is actually something that is really, really cool about Rust. And I don't know if there's any other ecosystem that has paid this much attention to like how your error messages look, right? Rather than just reporting like your line number or whatever.
So it's, I think that kind of style of like high quality error reporting is actually something that is really, really cool about Rust. And I don't know if there's any other ecosystem that has paid this much attention to like how your error messages look, right? Rather than just reporting like your line number or whatever.
Yes. Yes, it is. Right. So as an example, actually, one of the examples is that you can integrate it with SOD JSON. So you can actually get great highlighting for which bit of a SOD JSON thing failed. And I think that's really cool.
Yes. Yes, it is. Right. So as an example, actually, one of the examples is that you can integrate it with SOD JSON. So you can actually get great highlighting for which bit of a SOD JSON thing failed. And I think that's really cool.
I think in general, though, there is some value in having, you know, the kind of thing I wrote, which is like, you have like a nested tree structure, right? And you are parsing through the nested tree structure.
I think in general, though, there is some value in having, you know, the kind of thing I wrote, which is like, you have like a nested tree structure, right? And you are parsing through the nested tree structure.
And you want to actually not just fail on the first error globally, but you have kind of a notion of like, you want to go through as much as possible and you want to collect as many errors as possible. And I have had to do that a few times, and I've pretty much handwritten something each time.
And you want to actually not just fail on the first error globally, but you have kind of a notion of like, you want to go through as much as possible and you want to collect as many errors as possible. And I have had to do that a few times, and I've pretty much handwritten something each time.
So that kind of suggests that maybe, I don't know if the audience has a suggestion for something that kind of does that. Otherwise, that might actually be worth doing and kind of putting out as a separate thing. Yeah, it is kind of a much bigger scope thing, but yeah.
So that kind of suggests that maybe, I don't know if the audience has a suggestion for something that kind of does that. Otherwise, that might actually be worth doing and kind of putting out as a separate thing. Yeah, it is kind of a much bigger scope thing, but yeah.
I have a pair of really, really cool SerD-related crates. So there is a crate called SerD-Ignored, and there is another crate called SerD-PathToError. So I think both of these are really good. And again, kind of coming at it from the you want to produce good error messages kind of thing, right?
I have a pair of really, really cool SerD-related crates. So there is a crate called SerD-Ignored, and there is another crate called SerD-PathToError. So I think both of these are really good. And again, kind of coming at it from the you want to produce good error messages kind of thing, right?
So one of the things that I've noticed when defining, say, a configuration file is that people will often misspell things, right? Surdy has this really cool deny unknown fields feature. Yeah, I love this. Right? So, and deny unknown fields is great, but sometimes you don't want an error, you instead want a warning. And Surdy ignored actually kind of lets you get that warning.