Skip to main content

raster_style/
error.rs

1use thiserror::Error;
2
3/// Stable, cross-language error category and optional field location.
4#[derive(Debug, Clone, Error)]
5#[error("{code}: {message}")]
6pub struct Error {
7    pub code: &'static str,
8    pub message: String,
9    pub path: String,
10}
11
12impl Error {
13    pub(crate) fn new(code: &'static str, message: impl Into<String>) -> Self {
14        Self {
15            code,
16            message: message.into(),
17            path: String::new(),
18        }
19    }
20
21    pub(crate) fn at(mut self, path: impl Into<String>) -> Self {
22        self.path = path.into();
23        self
24    }
25}
26
27pub type Result<T> = std::result::Result<T, Error>;