mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-17 01:12:41 +00:00
Manually implement Error for ShaderError (#2160)
This commit is contained in:
parent
693bc58bdd
commit
7e00abf651
@ -5,7 +5,7 @@ use crate::{
|
||||
id::{DeviceId, PipelineLayoutId, ShaderModuleId},
|
||||
validation, Label, LifeGuard, Stored,
|
||||
};
|
||||
use std::{borrow::Cow, fmt};
|
||||
use std::{borrow::Cow, error::Error, fmt};
|
||||
use thiserror::Error;
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
@ -46,11 +46,10 @@ impl<A: hal::Api> Resource for ShaderModule<A> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Error)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ShaderError<E> {
|
||||
pub source: String,
|
||||
pub label: Option<String>,
|
||||
#[source]
|
||||
pub inner: E,
|
||||
}
|
||||
impl fmt::Display for ShaderError<naga::front::wgsl::ParseError> {
|
||||
@ -91,6 +90,15 @@ impl fmt::Display for ShaderError<naga::WithSpan<naga::valid::ValidationError>>
|
||||
)
|
||||
}
|
||||
}
|
||||
impl<E> Error for ShaderError<E>
|
||||
where
|
||||
ShaderError<E>: fmt::Display,
|
||||
E: Error + 'static,
|
||||
{
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
Some(&self.inner)
|
||||
}
|
||||
}
|
||||
|
||||
//Note: `Clone` would require `WithSpan: Clone`.
|
||||
#[derive(Debug, Error)]
|
||||
|
Loading…
Reference in New Issue
Block a user