Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error formatting #2205

Merged
merged 2 commits into from
May 12, 2023
Merged

Improve error formatting #2205

merged 2 commits into from
May 12, 2023

Conversation

marc0246
Copy link
Contributor

@marc0246 marc0246 commented May 12, 2023

This PR mainly aims to address the issue that errors are not formatted nicely when using Result::unwrap or Result::expect.

The formatting now looks like this, using a random validation error:

called `Result::unwrap()` on an `Err` value: a validation error occurred

Caused by:
    `create_info.subpasses[0].view_mask`: is not `0`

Requires one of:
    The `multiview` feature

Vulkan VUIDs:
    VUID-VkSubpassDescription2-multiview-06558

I mainly took inspiration from anyhow for the formatting.

Runtime errors look like this:

called `Result::unwrap()` on an `Err` value: a runtime error occurred: a device memory allocation has failed

I also changed the existing Display implementation for RequiresOneOf a little, to make it clearer that e.g. you need of of the features, not all of the features.

It's important to note that old error types using RequiresOneOf are going to have a strange mix of the debug formattings until we replace them, so let's preferably do that soon. Not world-ending though.

@marc0246 marc0246 changed the title Error formatting Improve error formatting May 12, 2023
@Rua Rua merged commit 535ae1a into vulkano-rs:master May 12, 2023
@marc0246 marc0246 deleted the error-formatting branch May 12, 2023 18:27
Rua added a commit that referenced this pull request May 31, 2023
hakolao pushed a commit to hakolao/vulkano that referenced this pull request Feb 20, 2024
* Add custom `Debug` implementations

* Minor improvements to `Display` implementations
hakolao pushed a commit to hakolao/vulkano that referenced this pull request Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants