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("PartialMap (map with hole keys) is not supported in JSON")]
10 PartialMapNotSupported { node_id: NodeId },
11
12 #[error("BigInt value is out of range for JSON number")]
13 BigIntOutOfRange { node_id: NodeId },
14
15 #[error("Non-finite floating point value (NaN or Infinity) is not supported in JSON")]
16 NonFiniteFloat { node_id: NodeId },
17
18 #[error("Variant content already contains tag field '{tag}' in Internal representation")]
19 VariantTagConflict { tag: String, node_id: NodeId },
20
21 #[error("Variant content already contains field '{field}' in Adjacent representation")]
22 VariantAdjacentConflict { field: String, node_id: NodeId },
23}
24
25impl EureToJsonError {
26 pub fn node_id(&self) -> NodeId {
28 match self {
29 EureToJsonError::HoleNotSupported { node_id } => *node_id,
30 EureToJsonError::PartialMapNotSupported { node_id } => *node_id,
31 EureToJsonError::BigIntOutOfRange { node_id } => *node_id,
32 EureToJsonError::NonFiniteFloat { node_id } => *node_id,
33 EureToJsonError::VariantTagConflict { node_id, .. } => *node_id,
34 EureToJsonError::VariantAdjacentConflict { node_id, .. } => *node_id,
35 }
36 }
37}
38
39#[derive(Debug, Error, PartialEq)]
43pub enum JsonToEureError {
44 }