use chrono::{DateTime, FixedOffset};
use thiserror::Error;
#[derive(Debug, Error)]
pub enum DetectionError {
#[error("unsupported detections file extension: {0:?}")]
UnsupportedExtension(String),
#[error("invalid detections schema: {0}")]
InvalidSchema(String),
#[error("detection parse error at {source_file}:{source_row}: {message}")]
Parse {
source_file: String,
source_row: usize,
message: String,
},
#[error("invalid timestamp at {source_file}:{source_row}: {message}")]
InvalidTimestamp {
source_file: String,
source_row: usize,
message: String,
},
#[error("invalid intrinsic value {value} at {source_file}:{source_row} (must be in [0, 1])")]
InvalidIntrinsic {
source_file: String,
source_row: usize,
value: f64,
},
#[error(
"missing crs at {source_file}:{source_row}: coordinate detections require an explicit CRS"
)]
MissingCrs {
source_file: String,
source_row: usize,
},
#[error(
"conflicting detections at {timestamp}: netelement '{netelement_a}' vs '{netelement_b}'"
)]
ConflictingDetections {
timestamp: DateTime<FixedOffset>,
netelement_a: String,
netelement_b: String,
},
#[error(
"invalid time range at {source_file}:{source_row}: t_from ({t_from}) is after t_to ({t_to})"
)]
InvalidTimeRange {
source_file: String,
source_row: usize,
t_from: DateTime<FixedOffset>,
t_to: DateTime<FixedOffset>,
},
#[error("unknown netelement '{netelement_id}' at {source_file}:{source_row}")]
UnknownNetelement {
source_file: String,
source_row: usize,
netelement_id: String,
},
#[error("duplicate resolution for detection at {source_file}:{source_row}")]
DuplicateResolution {
source_file: String,
source_row: usize,
},
#[error("detection IO error: {0}")]
Io(#[from] std::io::Error),
}