Skip to content

Commit

Permalink
Introduce custom Error type
Browse files Browse the repository at this point in the history
So far the crate has used std::io::Error as its error type. It is
sufficient for the most part, but it's not optimal long-term:
- by not abstracting it we are not very flexible once we need additional
  "kinds" or variants in the future
  - that also applies to features such as capturing of backtraces at
    time of error
- because it is defined outside of our crate, certain usability
  limitations may be imposed on us
  - io::Error does not lend itself to proper error chaining and that
    will make it harder to contextualize errors as the code base grows

To fix these issues, this change introduces a new public error type. The
type is still very close to io::Error, just by virtue of us doing a lot
of IO and so it is a natural fit. We certainly mirror several of the
std::io::ErrorKind variants in our own version of ErrorKind. On top of
of the error itself we also add a bunch of convenience conversion
functions, mostly to provide additional context. These are heavily
inspired by anyhow's Error type. That crate also acted as role model for
the way we format our errors.

Signed-off-by: Daniel Müller <deso@posteo.net>
  • Loading branch information
d-e-s-o committed Jul 14, 2023
1 parent b6856fb commit df959af
Show file tree
Hide file tree
Showing 3 changed files with 489 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Unreleased
----------
- Introduced custom `Error` type instead of relying solely on
`std::io::Error`
- Switched to using `gimli` for DWARF support
- Added support for DWARF versions v2, v3, and v5 for symbol lookup and source
code information retrieval
Expand Down
Loading

0 comments on commit df959af

Please sign in to comment.