mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 14:08:32 +00:00
# Objective - [`thiserror`](https://docs.rs/thiserror/) is used to derive the error type on `bevy_dynamic_plugin`'s [`DynamicPluginLoadError`](https://docs.rs/bevy_dynamic_plugin/latest/bevy_dynamic_plugin/enum.DynamicPluginLoadError.html). - It is an enum where each variant wraps a `libloading` error type. - `thiserror` supports marking this internal error types as `#[source]` so it can automatically fill out the [`Error::source`](https://doc.rust-lang.org/std/error/trait.Error.html#method.source) method. - This allows other error handling libraries to get more information about the error than what Bevy by default provides. It increases interoperability between libraries. ## Solution - Mark the internal `libloading::Error` of `DynamicPluginLoadError` with `#[source]`. --- ## Changelog - Implemented the [`Error::source`](https://doc.rust-lang.org/std/error/trait.Error.html#method.source) method for [`DynamicPluginLoadError`](https://docs.rs/bevy_dynamic_plugin/latest/bevy_dynamic_plugin/enum.DynamicPluginLoadError.html). --- Here is the output from `cargo-expand` before and after the change. ```rust // Before impl Error for DynamicPluginLoadError {} ``` ```rust // After impl Error for DynamicPluginLoadError { fn source(&self) -> Option<&(dyn Error + 'static)> { use thiserror::__private::AsDynError as _; match self { DynamicPluginLoadError::Library { 0: source, .. } => { Some(source.as_dyn_error()) } DynamicPluginLoadError::Plugin { 0: source, .. } => { Some(source.as_dyn_error()) } } } } ``` |
||
---|---|---|
.. | ||
bevy_a11y | ||
bevy_animation | ||
bevy_app | ||
bevy_asset | ||
bevy_audio | ||
bevy_core | ||
bevy_core_pipeline | ||
bevy_derive | ||
bevy_diagnostic | ||
bevy_dylib | ||
bevy_dynamic_plugin | ||
bevy_ecs | ||
bevy_ecs_compile_fail_tests | ||
bevy_encase_derive | ||
bevy_gilrs | ||
bevy_gizmos | ||
bevy_gltf | ||
bevy_hierarchy | ||
bevy_input | ||
bevy_internal | ||
bevy_log | ||
bevy_macro_utils | ||
bevy_macros_compile_fail_tests | ||
bevy_math | ||
bevy_mikktspace | ||
bevy_pbr | ||
bevy_ptr | ||
bevy_reflect | ||
bevy_reflect_compile_fail_tests | ||
bevy_render | ||
bevy_scene | ||
bevy_sprite | ||
bevy_tasks | ||
bevy_text | ||
bevy_time | ||
bevy_transform | ||
bevy_ui | ||
bevy_utils | ||
bevy_window | ||
bevy_winit |