Skip to content

wgpu often panics on errors #3777

@emilk

Description

@emilk

For instance, I get this in my browser:

Error] panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_render_pipeline
    Color state [0] is invalid
    Format Rgba8UnormSrgb can't be multisampled

', /home/jp/.cargo/git/checkouts/wgpu-b5b0e12eef369ba9/de497ae/wgpu/src/backend/direct.rs:3019:5

The error message is pretty good, but I would prefer to get an Err instead of a panic.

Here is the code from wgpu/src/backend/direct.rs:

    #[track_caller]
    fn handle_error_fatal(
        &self,
        cause: impl Error + Send + Sync + 'static,
        operation: &'static str,
    ) -> ! {
        panic!("Error in {operation}: {f}", f = self.format_error(&cause));
    }

This is not a big problem; if returning a Result would be extremely annoying for some reason, then the current behavior is good enough, but usually it is bad manners for a library to panic when it could use Result instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions