From ab0e3f871452f6be5c99f18175a8949b8a19e2dd Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Wed, 12 Mar 2025 20:13:02 -0400 Subject: [PATCH] Small cleanup for ECS error handling (#18280) # Objective While poking at https://github.com/bevyengine/bevy/issues/17272, I noticed a few small things to clean up. ## Solution - Improve the docs - ~~move `SystemErrorContext` out of the `handler.rs` module: it's not an error handler~~ --- crates/bevy_app/src/app.rs | 2 +- crates/bevy_app/src/sub_app.rs | 2 +- crates/bevy_ecs/src/error/mod.rs | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index 20f15bb098..9ce162d217 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -1276,7 +1276,7 @@ impl App { /// Set the global system error handler to use for systems that return a [`Result`]. /// - /// See the [`bevy_ecs::result` module-level documentation](../../bevy_ecs/result/index.html) + /// See the [`bevy_ecs::error` module-level documentation](bevy_ecs::error) /// for more information. pub fn set_system_error_handler( &mut self, diff --git a/crates/bevy_app/src/sub_app.rs b/crates/bevy_app/src/sub_app.rs index 0cb50ac887..7d0dfd3106 100644 --- a/crates/bevy_app/src/sub_app.rs +++ b/crates/bevy_app/src/sub_app.rs @@ -338,7 +338,7 @@ impl SubApp { /// Set the global error handler to use for systems that return a [`Result`]. /// - /// See the [`bevy_ecs::result` module-level documentation](../../bevy_ecs/result/index.html) + /// See the [`bevy_ecs::error` module-level documentation](bevy_ecs::error) /// for more information. pub fn set_system_error_handler( &mut self, diff --git a/crates/bevy_ecs/src/error/mod.rs b/crates/bevy_ecs/src/error/mod.rs index 307d93158f..4c8ad10d8e 100644 --- a/crates/bevy_ecs/src/error/mod.rs +++ b/crates/bevy_ecs/src/error/mod.rs @@ -8,10 +8,10 @@ //! [`panic`] error handler function is used, resulting in a panic with the error message attached. //! //! You can change the default behavior by registering a custom error handler, either globally or -//! per `Schedule`: +//! per [`Schedule`]: //! -//! - [`App::set_system_error_handler`] sets the global error handler for all systems of the -//! current [`World`]. +//! - `App::set_system_error_handler` (via `bevy_app`) sets the global error handler for all systems of the +//! current [`World`] by modifying the [`DefaultSystemErrorHandler`]. //! - [`Schedule::set_error_handler`] sets the error handler for all systems of that schedule. //! //! Bevy provides a number of pre-built error-handlers for you to use: @@ -76,5 +76,7 @@ mod handler; pub use bevy_error::*; pub use handler::*; -/// A result type for use in fallible systems. +/// A result type for use in fallible systems, commands and observers. +/// +/// The [`BevyError`] type is a type-erased error type with optional Bevy-specific diagnostics. pub type Result = core::result::Result;