Skip to content

Request: Switch away from Anyhow for the library crate #224

@laundmo

Description

@laundmo

Anyhow should only be used for binary crates which won't have dependents.

This is due to the way Anyhow hides the actual error types. As a developer relying on a library, I may want to handle errors returned by library calls depending on what the error actually is, not just the fact there was an error. Anyhow makes that impossible, as it completely strips typing from errors. Note that Anyhow itself agrees with this:

Use Anyhow if you don't care what error type your functions return, you just want it to be easy. This is common in application code. Use thiserror if you are a library that wants to design your own dedicated error type(s) so that on failures the caller gets exactly the information that you choose.

As Anyhow does, i recommend using thiserror. It allows you to easily expose the actual error types using a enum, or define your own.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions