Skip to main content

boundary_compiler/
error.rs

1//! Error types for boundary-compiler.
2
3use thiserror::Error;
4
5/// Errors that can occur during JCS canonicalization or boundary profile processing.
6#[derive(Debug, Error)]
7pub enum JcsError {
8    /// Duplicate object key encountered (violates RFC 8785 ยง2.7).
9    #[error("duplicate object key: {key:?}")]
10    DuplicateKey { key: String },
11
12    /// Invalid JSON structure during canonicalization.
13    #[error("invalid JSON: {reason}")]
14    InvalidJson { reason: String },
15
16    /// JSON lexer/syntax error.
17    #[error("JSON parse error: {0}")]
18    ParseError(#[from] serde_json::Error),
19
20    /// Schema validation failed.
21    #[error("schema validation failed: {0}")]
22    SchemaValidation(String),
23
24    /// JSON Schema initialization error.
25    #[error("JSON Schema error: {0}")]
26    SchemaError(String),
27
28    /// ContentDigest computation error.
29    #[error("digest error: {0}")]
30    DigestError(String),
31
32    /// Invalid profile configuration.
33    #[error("invalid profile: {reason}")]
34    InvalidProfile { reason: String },
35
36    /// Resource ceiling exceeded.
37    #[error("resource ceiling exceeded: {resource} ({used} / {limit})")]
38    ResourceCeilingExceeded {
39        resource: String,
40        used: usize,
41        limit: usize,
42    },
43}