codec_jcs/error.rs
1// SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
2//
3// SPDX-License-Identifier: Apache-2.0
4
5use thiserror::Error;
6
7/// Error returned when JSON canonicalization (JCS) fails.
8#[derive(Debug, Error, PartialEq, Eq)]
9pub enum JcsError {
10 /// A number was NaN or infinite, which JCS does not permit.
11 #[error("jcs: non-finite number is not allowed")]
12 NonFiniteNumber,
13
14 /// Serializing the value to canonical JSON failed.
15 #[error("jcs: JSON serialization error")]
16 SerializationError,
17
18 /// Nesting exceeded [`MAX_NESTING_DEPTH`](crate::MAX_NESTING_DEPTH).
19 /// A defense-in-depth bound in case a caller builds or deserializes a
20 /// `serde_json::Value` without the parser's own depth limit.
21 #[error("jcs: nesting depth limit exceeded")]
22 DepthExceeded,
23}