mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
0cfdbddf2e
# Objective Currently, `bevy_dynamic_plugin` simply panics on error. This makes it impossible to handle failures in applications that use this feature. For example, I'd like to build an optional expansion for my game, that may not be distributed to all users. I want to use `bevy_dynamic_plugin` for loading it. I want my game to try to load it on startup, but continue without it if it cannot be loaded. ## Solution - Make the `dynamically_load_plugin` function return a `Result`, so it can gracefully return loading errors. - Create an error enum type, to provide useful information about the kind of error. This adds `thiserror` to the dependencies of `bevy_dynamic_plugin`, but that dependency is already used in other parts of bevy (such as `bevy_asset`), so not a big deal. I chose not to change the behavior of the builder method in the App extension trait. I kept it as panicking. There is no clean way (that I'm aware of) to make a builder-style API that has fallible methods. So it is either a panic or a warning. I feel the panic is more appropriate. --- ## Changelog ### Changed - `bevy_dynamic_plugin::dynamically_load_plugin` now returns `Result` instead of panicking, to allow for error handling
19 lines
538 B
TOML
19 lines
538 B
TOML
[package]
|
|
name = "bevy_dynamic_plugin"
|
|
version = "0.9.0-dev"
|
|
edition = "2021"
|
|
description = "Provides dynamic plugin loading capabilities for non-wasm platforms"
|
|
homepage = "https://bevyengine.org"
|
|
repository = "https://github.com/bevyengine/bevy"
|
|
license = "MIT OR Apache-2.0"
|
|
keywords = ["bevy"]
|
|
|
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
|
|
[dependencies]
|
|
# bevy
|
|
bevy_app = { path = "../bevy_app", version = "0.9.0-dev" }
|
|
|
|
# other
|
|
libloading = { version = "0.7" }
|
|
thiserror = "1.0"
|