Skip to content

Built-in commands should return Results whenever possible #17271

@alice-i-cecile

Description

@alice-i-cecile

First: I'll note that most of the built in commands as phrased in #17043 do not (yet) return errors, and I think updating everything is out of scope for this PR.

That being said, multiple paths have been laid for built-in commands to return handled errors.

The first path: all built-in commands are now exported as functions in the command and entity_command modules. If any of them were rephrased to return an error, then this would immediately be possible:

entity.queue_fallible(insert(Team::Blue).handle_error_with(warn()));

The more common case of using the built-in shorthand functions would use the default global error handler, which defaults to panicking but can be configured:

entity.insert(Team::Blue);

Originally posted by @cart in #17215 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-BlessedHas a large architectural impact or tradeoffs, but the design has been endorsed by decision makers

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions