use std::io;
use std::path::PathBuf;
use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum StateError {
#[error("failed to read state template `{path}`")]
TemplateRead {
path: PathBuf,
#[source]
source: io::Error,
},
#[error("failed to parse state template `{path}` as JSON")]
TemplateParse {
path: PathBuf,
#[source]
source: serde_json::Error,
},
#[error("state template field at index {index} has an empty name")]
EmptyFieldName {
index: usize,
},
#[error("state template declares duplicate field `{field}`")]
DuplicateField {
field: String,
},
#[error("state template field `{field}` has an empty type tag")]
EmptyTypeTag {
field: String,
},
#[error("state template does not declare field `{field}`")]
UnknownField {
field: String,
},
#[error("state field `{field}` does not contain a payload")]
MissingValue {
field: String,
},
#[error("state field `{field}` contains `{actual}`, but the operation requested `{expected}`")]
TypeMismatch {
field: String,
expected: &'static str,
actual: &'static str,
},
#[error("state payload has {actual} field slots, but its template declares {expected}")]
FieldCountMismatch {
expected: usize,
actual: usize,
},
}