1use std::fmt;
4
5#[derive(Debug, thiserror::Error)]
7#[non_exhaustive]
8pub enum VictauriError {
9 #[error("capacity limit exceeded: {message}")]
10 CapacityExceeded { message: String },
11
12 #[error("serialization error: {0}")]
13 Serialization(#[from] serde_json::Error),
14
15 #[error("invalid input: {message}")]
16 InvalidInput { message: String },
17
18 #[error("no active recording session")]
19 NoActiveRecording,
20
21 #[error("recording session already active")]
22 RecordingAlreadyActive,
23
24 #[error("checkpoint not found: {id}")]
25 CheckpointNotFound { id: String },
26
27 #[error("command not found: {name}")]
28 CommandNotFound { name: String },
29
30 #[error("invalid ref handle: {ref_id}")]
31 InvalidRefHandle { ref_id: String },
32
33 #[error("unknown assertion condition: {condition}")]
34 UnknownCondition { condition: String },
35}
36
37pub type Result<T> = std::result::Result<T, VictauriError>;
38
39impl VictauriError {
40 pub fn capacity_exceeded(message: impl fmt::Display) -> Self {
41 Self::CapacityExceeded {
42 message: message.to_string(),
43 }
44 }
45 pub fn invalid_input(message: impl fmt::Display) -> Self {
46 Self::InvalidInput {
47 message: message.to_string(),
48 }
49 }
50}