Moving error formatting from wgpu-rs to wgpu-core #1082
Labels
area: validation
Issues related to validation, diagnostics, and error handling
help required
We need community help to make this happen.
type: enhancement
New feature or request
As discussed in #1068 it may be that some of the error formatting that is now in wgpu-rs should in fact be moved to wgpu-core.
As I don't have time to do help with it right now, I wanted to write down the steps I was thinking about it so that I don't forget. Also maybe it helps if anyone else is willing to help with this one.
The
format_error
in wgpu-rserror.rs
is the one that should end up either in directly toGlobal
, or as a separate helper that takesGlobal
as argument (It is basically doing that throughContext
now). Trivial in itself, but it depend onfmt_pretty_any
fmt_pretty_any
is what is doing the downcasting of errors, and mostly could just be moved to wgpu-core as-is, but it also downcasts theContextError
that is more specific to wgpu-rs.The
ContextError
is used to decorate the api calls in wgpu-rs for which api call the error came from. This was initially done because it had convenient access to the descriptor label, even when nothing was created on errors, as the errorId
s were created on wgpu-rs error side, but since this was changed in #1034, it does not need to be in wgpu-rs side anymore.So working backwards,
• Move/add
ContextError
to wgpu-core• Decorate the api call sites in wgpu-core
• Remove the
ContextError
decoration in wgpu-rshandle_error
• Now all of error.rs could be moved in wgpu-core (and slight tweak to
handle_error
to call theformat_error
in its new place)Alternatively, if just having some working
format_error
is deemed more important and waffing about theContextError
is boring busywork to be done later,• Move
PrettyError
trait and its impls (except for the ContextError)• Add some hook (callback?) to
format_error
/fmt_pretty_any
that allows wgpu-rs to inject its error to be downcasted• Move
format_error
to core. That should leave only theContextError
related stuff in error.rsThat was quite a lot of text, what is ultimately fairly simple set of changes.
The text was updated successfully, but these errors were encountered: