forked from ISISNeutronMuon/digital-muon-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.rs
More file actions
100 lines (95 loc) · 3.49 KB
/
error.rs
File metadata and controls
100 lines (95 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use crate::{hdf5_handlers::NexusHDF5Error, run_engine::NexusDateTime};
use glob::{GlobError, PatternError};
use rdkafka::error::KafkaError;
use std::{num::TryFromIntError, path::PathBuf};
use supermusr_streaming_types::time_conversions::GpsTimeConversionError;
use thiserror::Error;
pub(crate) type NexusWriterResult<T> = Result<T, NexusWriterError>;
#[derive(Debug, strum::Display)]
pub(crate) enum ErrorCodeLocation {
#[strum(to_string = "flush_to_archive")]
FlushToArchive,
#[strum(to_string = "RunParameters::new")]
NewRunParamemters,
#[strum(to_string = "process_event_list")]
ProcessEventList,
#[strum(to_string = "resume_partial_runs file path")]
ResumePartialRunsFilePath,
#[strum(to_string = "resume_partial_runs local directory path")]
ResumePartialRunsLocalDirectoryPath,
#[strum(to_string = "set_aborted_run")]
SetAbortedRun,
#[strum(to_string = "set_stop_if_valid")]
SetStopIfValid,
#[strum(to_string = "stop_command")]
StopCommand,
}
#[derive(Debug, Error)]
pub(crate) enum NexusWriterError {
#[error("{0}")]
HDF5(#[from] NexusHDF5Error),
#[error("Glob Pattern Error: {0}")]
GlobPattern(#[from] PatternError),
#[error("Glob Error: {0}")]
Glob(#[from] GlobError),
#[error("IO Error: {0}")]
IO(#[from] std::io::Error),
#[error("Integer Conversion Error")]
TryFromInt(#[from] TryFromIntError),
#[error("Flatbuffer Timestamp Conversion Error {0}")]
FlatBufferTimestampConversion(#[from] GpsTimeConversionError),
#[error("{0} at {1}")]
FlatBufferMissing(FlatBufferMissingError, ErrorCodeLocation),
#[error("Kafka Error: {0}")]
KafkaError(#[from] KafkaError),
#[error("Cannot convert local path to string: {path} at {location}")]
CannotConvertPath {
path: PathBuf,
location: ErrorCodeLocation,
},
#[error("Start Time {int} Out of Range for DateTime at {location}")]
IntOutOfRangeForDateTime {
int: u64,
location: ErrorCodeLocation,
},
#[error("Stop Command before Start Command at {0}")]
StopCommandBeforeStartCommand(ErrorCodeLocation),
#[error("Stop Time {stop} earlier than current Start Time {start} at {location}")]
StopTimeEarlierThanStartTime {
start: NexusDateTime,
stop: NexusDateTime,
location: ErrorCodeLocation,
},
#[error("RunStop already set at {0}")]
RunStopAlreadySet(ErrorCodeLocation),
#[error("Unexpected RunStop Command at {0}")]
RunStopUnexpected(ErrorCodeLocation),
}
#[derive(Debug, strum::Display)]
pub(crate) enum FlatBufferInvalidDataTypeContext {
#[strum(to_string = "Run Log")]
RunLog,
#[strum(to_string = "Sample Environment Log")]
SELog,
}
#[derive(Debug, Error)]
pub(crate) enum FlatBufferMissingError {
#[error("Timestamp Missing from Flatbuffer FrameEventList Message")]
Timestamp,
#[error("Channels Missing from Flatbuffer FrameEventList Message")]
Channels,
#[error("Intensities Missing from Flatbuffer FrameEventList Message")]
Intensities,
#[error("Times Missing from Flatbuffer FrameEventList Message")]
Times,
#[error("Run Name Missing from Flatbuffer RunStart Message")]
RunName,
#[error("Instrument Name Missing from Flatbuffer RunStart Message")]
InstrumentName,
#[error("Source Name Missing from Flatbuffer Alarm Message")]
AlarmName,
#[error("Severity Missing from Flatbuffer Alarm Message")]
AlarmSeverity,
#[error("Status Missing from Flatbuffer Alarm Message")]
AlarmMessage,
}