ephemeris_documents/error/
annotation.rs1use std::fmt;
4
5use facet_value::ValueError as FacetValueError;
6
7#[derive(Debug, thiserror::Error)]
9pub enum AnnotationError {
10 #[error("annotation marker is malformed")]
12 Marker {
13 #[source]
15 source: Box<FacetValueError>,
16 },
17 #[error("annotation marker has no `value` field")]
19 MissingValue,
20 #[error("annotation sets field `{field}` more than once")]
22 FieldSetTwice {
23 field: MarkerField,
25 },
26 #[error("annotation requests a string style for a value that is not a string")]
28 StyleOnNonString,
29 #[error("annotation sets `order` on a value that is not an object entry")]
31 OrderOutsideObject,
32 #[error("annotation requests a dotted table for a value that is not an object")]
34 DottedOnNonObject,
35}
36
37#[derive(Debug, Clone, Copy, PartialEq, Eq)]
39pub enum MarkerField {
40 Order,
42 String,
44 Comment,
46 Dotted,
48}
49
50impl fmt::Display for MarkerField {
51 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
52 f.write_str(match self {
53 Self::Order => "order",
54 Self::String => "string",
55 Self::Comment => "comment",
56 Self::Dotted => "dotted",
57 })
58 }
59}