script/dom/webgpu/
gpupipelineerror.rs1use dom_struct::dom_struct;
6use js::context::JSContext;
7use js::rust::HandleObject;
8use script_bindings::reflector::reflect_dom_object_with_proto_and_cx;
9
10use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
11 GPUPipelineErrorInit, GPUPipelineErrorMethods, GPUPipelineErrorReason,
12};
13use crate::dom::bindings::root::DomRoot;
14use crate::dom::bindings::str::DOMString;
15use crate::dom::domexception::DOMException;
16use crate::dom::globalscope::GlobalScope;
17
18#[dom_struct]
20pub(crate) struct GPUPipelineError {
21 exception: DOMException,
22 reason: GPUPipelineErrorReason,
23}
24
25impl GPUPipelineError {
26 fn new_inherited(message: DOMString, reason: GPUPipelineErrorReason) -> Self {
27 Self {
28 exception: DOMException::new_inherited(message, "GPUPipelineError".into()),
29 reason,
30 }
31 }
32
33 pub(crate) fn new_with_proto(
34 cx: &mut JSContext,
35 global: &GlobalScope,
36 proto: Option<HandleObject>,
37 message: DOMString,
38 reason: GPUPipelineErrorReason,
39 ) -> DomRoot<Self> {
40 reflect_dom_object_with_proto_and_cx(
41 Box::new(Self::new_inherited(message, reason)),
42 global,
43 proto,
44 cx,
45 )
46 }
47
48 pub(crate) fn new(
49 cx: &mut JSContext,
50 global: &GlobalScope,
51 message: DOMString,
52 reason: GPUPipelineErrorReason,
53 ) -> DomRoot<Self> {
54 Self::new_with_proto(cx, global, None, message, reason)
55 }
56}
57
58impl GPUPipelineErrorMethods<crate::DomTypeHolder> for GPUPipelineError {
59 fn Constructor(
61 cx: &mut JSContext,
62 global: &GlobalScope,
63 proto: Option<HandleObject>,
64 message: DOMString,
65 options: &GPUPipelineErrorInit,
66 ) -> DomRoot<Self> {
67 Self::new_with_proto(cx, global, proto, message, options.reason)
68 }
69
70 fn Reason(&self) -> GPUPipelineErrorReason {
72 self.reason
73 }
74}