1use eure_document::document::NodeId;
2use thiserror::Error;
3
4#[derive(Debug, Clone, Error, PartialEq)]
5pub enum EureToJsonError {
6 #[error("Hole (uninitialized value) is not supported in JSON")]
7 HoleNotSupported { node_id: NodeId },
8
9 #[error("BigInt value is out of range for JSON number")]
10 BigIntOutOfRange { node_id: NodeId },
11
12 #[error("Non-finite floating point value (NaN or Infinity) is not supported in JSON")]
13 NonFiniteFloat { node_id: NodeId },
14
15 #[error("Variant content already contains tag field '{tag}' in Internal representation")]
16 VariantTagConflict { tag: String, node_id: NodeId },
17
18 #[error("Variant content already contains field '{field}' in Adjacent representation")]
19 VariantAdjacentConflict { field: String, node_id: NodeId },
20}
21
22impl EureToJsonError {
23 pub fn node_id(&self) -> NodeId {
25 match self {
26 EureToJsonError::HoleNotSupported { node_id } => *node_id,
27 EureToJsonError::BigIntOutOfRange { node_id } => *node_id,
28 EureToJsonError::NonFiniteFloat { node_id } => *node_id,
29 EureToJsonError::VariantTagConflict { node_id, .. } => *node_id,
30 EureToJsonError::VariantAdjacentConflict { node_id, .. } => *node_id,
31 }
32 }
33}
34
35#[derive(Debug, Error, PartialEq)]
39pub enum JsonToEureError {
40 }