kata/error
Types
pub type Error {
Error(
path: List(PathSegment),
issue: Issue,
schema_name: option.Option(String),
)
}
Constructors
-
Error( path: List(PathSegment), issue: Issue, schema_name: option.Option(String), )
pub type Issue {
TypeMismatch(expected: String, got: String)
MissingField(name: String)
RefinementFailed(name: String, message: String)
UnionNoMatch(
discriminator: String,
tried: List(String),
got: String,
)
Custom(message: String)
}
Constructors
-
TypeMismatch(expected: String, got: String)Type mismatch
-
MissingField(name: String)Required field missing
-
RefinementFailed(name: String, message: String)Refinement check failed
-
UnionNoMatch( discriminator: String, tried: List(String), got: String, )No variant matched in tagged union
-
Custom(message: String)Custom error
pub type PathSegment {
Key(String)
Index(Int)
Variant(String)
}
Constructors
-
Key(String) -
Index(Int) -
Variant(String)
Values
pub fn format_error(e: Error) -> String
Format a single error as a human-readable string
pub fn path_to_string(path: List(PathSegment)) -> String
Format a path as a human-readable string (e.g. “$.user.age”)
pub fn prepend_path(
errors: List(Error),
segment: PathSegment,
) -> List(Error)
Prepend a path segment to all errors