bevyengine / bevyengine/bevy

Fallible plugins creation

Open
#2,337 12 comments 2 reactions 0 assignees View on GitHub
A-App C-Feature C-Usability
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

Allow plugins to fail gracefully if their configuration is invalid.

## What solution would you like?

Make `Plugin::build` return a `Result`, which should be propagated to `add_plugin` method.

## What alternative(s) have you considered?

Panic on error.

## Additional context

This feature would be needed for the XR integration, both for the OpenXR backend and a future WebXR backend. OpenXR can fail if the OpenXR runtime is not available or a XR device was not found. WebXR can fail if the host device does not support the selected session mode. `panic!()` is especially a bad choice when running on web since the bevy app would be only a part of a webpage and bailing out completely would not be acceptable.

## Downsides

Every plugin must be updated to return `Result`. The user has to explicitly handle errors after each `add_plugin` call.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.