use serde::{Deserialize, Serialize};
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum MigError {
#[error("existence check failed: {0}")]
Existence(#[from] ExistenceError),
#[error("lift failed: {0}")]
Lift(#[from] LiftError),
#[error("compose failed: {0}")]
Compose(#[from] ComposeError),
#[error("inversion failed: {0}")]
Invert(#[from] InvertError),
}
#[derive(Debug, Clone, Serialize, Deserialize, thiserror::Error)]
#[non_exhaustive]
pub enum ExistenceError {
#[error("edge missing: {src} -> {tgt} (kind: {kind})")]
EdgeMissing {
src: String,
tgt: String,
kind: String,
},
#[error("kind inconsistency for {kind}: targets = {targets:?}")]
KindInconsistency {
kind: String,
targets: Vec<String>,
},
#[error("label inconsistency for {label}: targets = {targets:?}")]
LabelInconsistency {
label: String,
targets: Vec<String>,
},
#[error("required field missing: vertex {vertex}, field {field}")]
RequiredFieldMissing {
vertex: String,
field: String,
},
#[error("constraint tightened on {vertex}: {sort} changed from {src_val} to {tgt_val}")]
ConstraintTightened {
vertex: String,
sort: String,
src_val: String,
tgt_val: String,
},
#[error("resolver invalid for pair ({}, {})", pair.0, pair.1)]
ResolverInvalid {
pair: (String, String),
},
#[error("well-formedness: {message}")]
WellFormedness {
message: String,
},
#[error("signature incoherent for hyper-edge {hyper_edge}: label {label}")]
SignatureCoherence {
hyper_edge: String,
label: String,
},
#[error("simultaneity violation for hyper-edge {hyper_edge}: missing label {missing_label}")]
Simultaneity {
hyper_edge: String,
missing_label: String,
},
#[error("reachability risk for vertex {vertex}: {reason}")]
ReachabilityRisk {
vertex: String,
reason: String,
},
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum LiftError {
#[error("restrict failed: {0}")]
Restrict(#[from] panproto_inst::RestrictError),
#[error("target schema is required for W-type lift")]
MissingTargetSchema,
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum ComposeError {
#[error("edge not found in second migration's domain: {src} -> {tgt} ({kind})")]
EdgeNotInDomain {
src: String,
tgt: String,
kind: String,
},
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum InvertError {
#[error("vertex map is not bijective: {detail}")]
NotBijective {
detail: String,
},
#[error("edge map is not bijective: {detail}")]
EdgeNotBijective {
detail: String,
},
#[error("migration drops vertices: {dropped:?}")]
DroppedVertices {
dropped: Vec<String>,
},
#[error("migration drops edges")]
DroppedEdges,
#[error("hyper-edge map is not bijective: {detail}")]
HyperEdgeNotBijective {
detail: String,
},
#[error("migration drops hyper-edges: {dropped:?}")]
DroppedHyperEdges {
dropped: Vec<String>,
},
}