Implement specific errors for parser types #152
Labels
complexity::low
Issues or ideas with a low implementation cost
component::cli
Everything related to the buffrs cli
docs::crate
Improvements or additions to documentation
priority::high
Urgent change or idea, please review quickly
type::refactoring
Changing the inner-workings of buffrs
Milestone
I would add a proper error type here. It is not too much work, and you have the benefit of having more readable code, because you are not mixing business logic and error messages. Additionally, it is much easier to use
miette
's advanced features such as error codes that way without cluttering the code itself too much.Example:
And then you use this in the code like this:
Only when you tie them all together (for example, in the
main
function) you should usemiette::Report
instead.My feeling is that I would not allow using
miette::Report
inFromStr
implementations. It is perfectly fine to use for themain
function, where you are tying together errors from various sources. But in things such asFromStr
orTryFrom
, I generally don't allow the use of non-structured errors.Originally posted by @xfbs in #131 (comment)
The text was updated successfully, but these errors were encountered: