use std::fmt;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("invalid JSON: {0}")]
Json(#[from] serde_json::Error),
#[error("could not interpret input as a {format} trace: {reason}")]
Shape {
format: &'static str,
reason: String,
},
#[error("could not auto-detect trace format; specify one explicitly")]
UnknownFormat,
#[error("invalid pattern `{pattern}`: {reason}")]
Pattern {
pattern: String,
reason: String,
},
#[error("invalid configuration: {0}")]
Config(String),
}
impl Error {
pub(crate) fn shape(format: &'static str, reason: impl fmt::Display) -> Self {
Error::Shape {
format,
reason: reason.to_string(),
}
}
}
pub type Result<T> = std::result::Result<T, Error>;