1use thiserror::Error;
4
5use crate::field_error::ValidationErrors;
6
7#[derive(Debug, Error)]
9#[non_exhaustive]
10pub enum DppError {
11 #[error("passport not found: {0}")]
12 NotFound(String),
13
14 #[error(
15 "passport is not in a state that allows this operation: current={current}, required={required}"
16 )]
17 InvalidTransition { current: String, required: String },
18
19 #[error("validation failed: {0}")]
20 Validation(ValidationErrors),
21
22 #[error("signing failed: {0}")]
23 Signing(String),
24
25 #[error("serialisation error: {0}")]
26 Serialisation(String),
27
28 #[error("stored data does not match the current schema: {0}")]
34 SchemaIncompatible(#[from] crate::schemas::lens::UpcastError),
35
36 #[error("passport is retention-locked: published passports cannot be deleted")]
41 RetentionLocked,
42
43 #[error("internal error: {0}")]
44 Internal(String),
45}
46
47impl From<ValidationErrors> for DppError {
48 fn from(errors: ValidationErrors) -> Self {
49 DppError::Validation(errors)
50 }
51}