sim_lib_music_serial/
error.rs1use thiserror::Error;
4
5use crate::{OrdinalRef, RowInstanceId, SerialEventId, SimultaneousGroupId, StructuralReadingId};
6
7#[derive(Clone, Debug, PartialEq, Eq, Error)]
9pub enum SerialPlanError {
10 #[error("invalid {kind} id {value:?}: {reason}")]
12 InvalidId {
13 kind: &'static str,
15 value: String,
17 reason: &'static str,
19 },
20 #[error("event {event_id} references unknown row {row_id}")]
22 UnknownRow {
23 event_id: SerialEventId,
25 row_id: RowInstanceId,
27 },
28 #[error(
30 "event {event_id} references ordinal {ordinal} outside row {row_id} with length {row_len}"
31 )]
32 OrdinalOutOfRange {
33 event_id: SerialEventId,
35 row_id: RowInstanceId,
37 ordinal: usize,
39 row_len: usize,
41 },
42 #[error("event {event_id} has role/origin mismatch: {reason}")]
44 RoleOriginMismatch {
45 event_id: SerialEventId,
47 reason: &'static str,
49 },
50 #[error("event {event_id} requires at least one parent for role {role}")]
52 MissingParents {
53 event_id: SerialEventId,
55 role: &'static str,
57 },
58 #[error("event {event_id} names unknown parent {parent_id}")]
60 UnknownParent {
61 event_id: SerialEventId,
63 parent_id: SerialEventId,
65 },
66 #[error("event {0} cannot name itself as a parent")]
68 SelfParent(SerialEventId),
69 #[error("parent evidence contains a cycle involving event {0}")]
71 ParentCycle(SerialEventId),
72 #[error("row {row_id} is missing structural coverage for ordinals {ordinals:?}")]
74 MissingStructuralCoverage {
75 row_id: RowInstanceId,
77 ordinals: Vec<usize>,
79 },
80 #[error("precedence graph names unknown event {0}")]
82 UnknownPrecedenceNode(SerialEventId),
83 #[error("precedence graph contains a self-edge on event {0}")]
85 SelfPrecedence(SerialEventId),
86 #[error("precedence graph contains a cycle involving event {0}")]
88 PrecedenceCycle(SerialEventId),
89 #[error("precedence graph orders simultaneous-group {group_id} members {before} and {after}")]
91 SimultaneousPrecedenceConflict {
92 group_id: SimultaneousGroupId,
94 before: SerialEventId,
96 after: SerialEventId,
98 },
99 #[error("event {0} must reference at least one structural ordinal")]
101 EmptyOrdinalSet(SerialEventId),
102 #[error("event {event_id} repeats ordinal reference {ordinal:?}")]
104 DuplicateOrdinal {
105 event_id: SerialEventId,
107 ordinal: OrdinalRef,
109 },
110 #[error("event {0} must declare at least one structural license")]
112 MissingStructuralLicenses(SerialEventId),
113 #[error("structural reading {0} must provide a non-empty rationale")]
115 EmptyStructuralLicenseRationale(StructuralReadingId),
116}