Skip to content

Update default error handler to use Severity.#23409

Merged
alice-i-cecile merged 1 commit intobevyengine:mainfrom
AlephCubed:DefaultErrorHandler
Mar 20, 2026
Merged

Update default error handler to use Severity.#23409
alice-i-cecile merged 1 commit intobevyengine:mainfrom
AlephCubed:DefaultErrorHandler

Conversation

@AlephCubed
Copy link
Contributor

@AlephCubed AlephCubed commented Mar 18, 2026

Followup to #22201. Includes the changes in #23408, which is currently in the queue.

Adds a new default error handler that defers to an error's Severity.

@kfc35
Copy link
Contributor

kfc35 commented Mar 18, 2026

The first two commits in this PR are the same as #23408 it looks like
Since that was merged just a bit ago, maybe a merge from main into this branch would help just to make sure the “Files Changed" actually reflects whats new

Edit: Oh I’m dumb, just read the description that it includes those changes 😅

@kfc35 kfc35 added the A-ECS Entities, components, systems, and events label Mar 18, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in ECS Mar 18, 2026
@kfc35 kfc35 added D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Mar 18, 2026
@AlephCubed AlephCubed force-pushed the DefaultErrorHandler branch from 6f2e1d8 to 59e8701 Compare March 18, 2026 20:24
@Freyja-moth
Copy link
Contributor

Might be worth having a match_error_up_to method that crashes on errors on and above the level specified.

@AlephCubed
Copy link
Contributor Author

That might be useful, but I think it would require something like:

match_severity_up_to::<{ Severity::Warning as u8 }>

since we don't have adt_const_params.

Alternatively we could have a separate handler for each case (match_severity_up_to_warning, match_severity_up_to_debug, etc).

@Freyja-moth
Copy link
Contributor

Freyja-moth commented Mar 19, 2026

couldn't you just do

#[track_caller]
#[inline]
pub fn match_severity_up_to(severity: Severity) -> impl Fn(BevyError, ErrorContext) {
    move |err, ctx| {
        ...
    }
}

@AlephCubed
Copy link
Contributor Author

I can't seem to get that to work (at least without changing the signature of DefaultErrorHandler). It always complains "expected fn pointer, found opaque type" or similar.

I'm not very experienced with function types, so I could totaly be missing something.

@Freyja-moth
Copy link
Contributor

at least without changing the signature of DefaultErrorHandler

I feel like that's an acceptable trade off. The error handler is the cold path so the extra bit of indirection from a function pointer is worth it I'd say (not certain but I'm fairly sure the cost of the indirection is out-shadowed by the cost of io from logging).

It's not a massive need so ultimately up to you, but it would be nice to have.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 20, 2026
Merged via the queue into bevyengine:main with commit 08c5dd3 Mar 20, 2026
38 checks passed
@github-project-automation github-project-automation bot moved this from Needs SME Triage to Done in ECS Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants