Skip to content

Can't use anyhow when writing custom AssetLoaders or AssetSavers #10350

@Runi-c

Description

@Runi-c

Bevy version

v0.12.0

What you did

Tried to use anyhow::Error as the value for the associated type Error in my implementation of an AssetLoader, as recommended in #10003.

What went wrong

error[E0277]: the trait bound `anyhow::Error: StdError` is not satisfied
   --> src\asset.rs:111:18
    |
111 |     type Error = anyhow::Error;
    |                  ^^^^^^^^^^^^^ the trait `StdError` is not implemented for `anyhow::Error`
    |
note: required by a bound in `bevy::asset::AssetLoader::Error`
   --> <snip>\bevy_asset\src\loader.rs:31:17
    |
31  |     type Error: std::error::Error + Send + Sync + 'static;
    |                 ^^^^^^^^^^^^^^^^^ required by this bound in `AssetLoader::Error`

Additional information

#10003 suggests that anyhow::Error is intended to be a drop-in replacement here, to make migrations easier. I had to add thiserror as a project dependency just for this one file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AssetsLoad files from disk to use for things like images, models, and soundsC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions