Skip to main content

oxicuda_nerf/
error.rs

1//! Error types for `oxicuda-nerf`.
2
3/// All errors that can be returned by `oxicuda-nerf` operations.
4#[derive(Debug, thiserror::Error)]
5pub enum NerfError {
6    #[error("dimension mismatch: expected {expected}, got {got}")]
7    DimensionMismatch { expected: usize, got: usize },
8
9    #[error("empty input")]
10    EmptyInput,
11
12    #[error("invalid frequency levels: {levels}")]
13    InvalidFreqLevels { levels: usize },
14
15    #[error("invalid hash grid config: {msg}")]
16    InvalidHashConfig { msg: String },
17
18    #[error("NaN encountered in {context}")]
19    NanEncountered { context: String },
20
21    #[error("invalid near/far bounds: near={near}, far={far}")]
22    InvalidBounds { near: f32, far: f32 },
23
24    #[error("invalid sample count: {n}")]
25    InvalidSampleCount { n: usize },
26
27    #[error("ray direction is zero or near-zero")]
28    ZeroRayDirection,
29
30    #[error("invalid camera intrinsics: {msg}")]
31    InvalidCameraIntrinsics { msg: String },
32
33    #[error("invalid grid resolution: {res}")]
34    InvalidGridResolution { res: usize },
35
36    #[error("hash level out of range: {level}")]
37    HashLevelOutOfRange { level: usize },
38
39    #[error("invalid feature dimension: {dim}")]
40    InvalidFeatureDim { dim: usize },
41
42    #[error("tensor decomp rank error: {msg}")]
43    TensorDecompError { msg: String },
44
45    #[error("volume render failed: {msg}")]
46    VolumeRenderError { msg: String },
47
48    #[error("internal error: {msg}")]
49    Internal { msg: String },
50}
51
52/// Convenience alias.
53pub type NerfResult<T> = Result<T, NerfError>;