Skip to content

[Feature]: Implement From<String> for errors #48

Description

@Shatur

Prerequisites

  • I have searched existing issues to ensure this isn't a duplicate

Problem Statement

Creating erros is not very ergonomic. Even using a helper method:

    userdata
        .borrow_mut::<T>(state)
        .ok_or_else(|| runtime_error(format!("unable to downcast to `{}`", any::type_name::<T>())))

Proposed Solution

We can implement conversion from string to allow this:

    userdata
        .borrow_mut::<T>(state)
        .ok_or_else(|| format!("unable to downcast to `{}`", any::type_name::<T>()).into())

That's what Bevy does for its own types.

Alternatives Considered

No response

Additional Context

No response

Implementation

  • I'm willing to implement this feature myself
  • I can help with testing and feedback

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions