Skip to main content

rfann/webgpu/
error.rs

1//! Error types for WebGPU compute backend
2
3use thiserror::Error;
4
5/// Errors that can occur during compute operations
6#[derive(Error, Debug)]
7pub enum ComputeError {
8    #[error("Backend initialization failed: {0}")]
9    InitializationError(String),
10
11    #[error("GPU not available or compatible")]
12    GpuUnavailable,
13
14    #[error("Buffer allocation failed: {0}")]
15    AllocationError(String),
16
17    #[error("Shader compilation failed: {0}")]
18    ShaderError(String),
19
20    #[error("Memory transfer failed: {0}")]
21    TransferError(String),
22
23    #[error("Compute operation failed: {0}")]
24    ComputeError(String),
25
26    #[error("Backend-specific error: {0}")]
27    BackendError(String),
28
29    #[error("Invalid dimensions: {0}")]
30    InvalidDimensions(String),
31
32    #[error("Unsupported operation: {0}")]
33    UnsupportedOperation(String),
34
35    #[error("Async operation error: {0}")]
36    AsyncError(String),
37
38    #[error("Memory error: {0}")]
39    MemoryError(String),
40
41    #[error("General error: {0}")]
42    General(String),
43}
44
45/// Result type for compute operations
46pub type ComputeResult<T> = Result<T, ComputeError>;