Replies: 1 comment 11 replies
-
I'll also link here uber style guide for errors. Regarding the cost of initialization of errors, have any of you seen an article or an opinion about this? |
Beta Was this translation helpful? Give feedback.
11 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Following #530, let's start the discussion here about what errors should look like and how they should be implemented.
I'll write up my thoughts later today, but feel free to start the discussion if you'd like!@vincentserpoul @moorereasonOverall I think the errors should help the user of the library understand what went wrong and give context to fix this. I think this means two things:
For the first point, I think encoding/json is a good model. For example:
Error messages a clear, and created at the point the error occurred. No need to wrap it. If we can't write an error message that accurately describes the issue without providing the call stack that means there is an issue in the structure of the code.
For the second point, I think it's mostly a matter of making sure all the errors that come from decoding are stored in a
toml.decodeError
. With this format, the top level function adds the surrounding lines in the file and highlight the bytes that caused the issue.Beta Was this translation helpful? Give feedback.
All reactions