mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
[rs] Add label for render pass context error
Also made the label key settable
This commit is contained in:
parent
db82edb31e
commit
dc61d7fb22
@ -1419,7 +1419,10 @@ impl crate::Context for Context {
|
|||||||
) {
|
) {
|
||||||
let global = &self.0;
|
let global = &self.0;
|
||||||
wgc::gfx_select!(encoder.id => global.command_encoder_run_render_pass(encoder.id, pass))
|
wgc::gfx_select!(encoder.id => global.command_encoder_run_render_pass(encoder.id, pass))
|
||||||
.map_err(|err| err.with_context("In a RenderPass", None))
|
.map_err(|err| {
|
||||||
|
let name = wgc::gfx_select!(encoder.id => global.command_buffer_label(encoder.id));
|
||||||
|
err.with_context_label_key("In a render pass", "encoder", Some(&name))
|
||||||
|
})
|
||||||
.unwrap_error_sink(&encoder.error_sink, &self, || ())
|
.unwrap_error_sink(&encoder.error_sink, &self, || ())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1578,15 +1581,29 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
trait WithContextError: Error + Send + Sync + 'static + Sized {
|
trait WithContextError: Error + Send + Sync + 'static + Sized {
|
||||||
fn with_context(self, string: &str, label: Option<&str>) -> ContextError;
|
fn with_context_label_key(
|
||||||
|
self,
|
||||||
|
string: &str,
|
||||||
|
label_key: &'static str,
|
||||||
|
label: Option<&str>,
|
||||||
|
) -> ContextError;
|
||||||
|
fn with_context(self, string: &str, label: Option<&str>) -> ContextError {
|
||||||
|
self.with_context_label_key(string, "label", label)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: Error + Send + Sync + 'static> WithContextError for E {
|
impl<E: Error + Send + Sync + 'static> WithContextError for E {
|
||||||
fn with_context(self, string: &str, label: Option<&str>) -> ContextError {
|
fn with_context_label_key(
|
||||||
|
self,
|
||||||
|
string: &str,
|
||||||
|
label_key: &'static str,
|
||||||
|
label: Option<&str>,
|
||||||
|
) -> ContextError {
|
||||||
ContextError {
|
ContextError {
|
||||||
string: string.to_string(),
|
string: string.to_string(),
|
||||||
cause: Box::new(self),
|
cause: Box::new(self),
|
||||||
label: label.unwrap_or("").to_string(),
|
label: label.unwrap_or("").to_string(),
|
||||||
|
label_key,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1595,6 +1612,7 @@ impl<E: Error + Send + Sync + 'static> WithContextError for E {
|
|||||||
pub(crate) struct ContextError {
|
pub(crate) struct ContextError {
|
||||||
pub string: String,
|
pub string: String,
|
||||||
pub cause: Box<dyn Error + Send + Sync + 'static>,
|
pub cause: Box<dyn Error + Send + Sync + 'static>,
|
||||||
|
pub label_key: &'static str,
|
||||||
pub label: String,
|
pub label: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -82,7 +82,7 @@ pub trait PrettyError: Error {
|
|||||||
|
|
||||||
impl PrettyError for super::direct::ContextError {
|
impl PrettyError for super::direct::ContextError {
|
||||||
fn fmt_pretty(&self, _context: &Context) -> String {
|
fn fmt_pretty(&self, _context: &Context) -> String {
|
||||||
format_error_line(self.as_display()) + &format_label_line("label", &self.label)
|
format_error_line(self.as_display()) + &format_label_line(self.label_key, &self.label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user