1use crate::PrefixMap;
2use iri_s::error::IriSError;
3use thiserror::Error;
4
5#[derive(Debug, Error, Clone)]
7pub enum PrefixMapError {
8 #[error(transparent)]
10 IriSError(#[from] IriSError),
11
12 #[error("Alias '{prefix}' not found in prefix map\nAvailable aliases: [{}]", prefixmap.aliases().cloned().collect::<Vec<_>>().join(", "))]
14 PrefixNotFound { prefix: String, prefixmap: PrefixMap },
15
16 #[error(transparent)]
18 FormatError(#[from] std::fmt::Error),
19
20 #[error("IO Error: {error}")]
22 IOError { error: String },
23
24 #[error("Alias '{prefix}' already exists in prefix map with value '{value}'")]
26 AliasAlreadyExists { prefix: String, value: String },
27}
28
29#[derive(Debug, Error, Clone)]
31#[error("Cannot obtain IRI from prefixed name IriRef {prefix}:{local}")]
32pub struct IriRefError {
33 pub prefix: String,
34 pub local: String,
35}
36
37#[derive(Debug, Error, Clone)]
39pub enum DerefError {
40 #[error(transparent)]
42 IriSError(#[from] IriSError),
43
44 #[error("Error obtaining IRI for '{alias}:{local}': {error}")]
49 DerefPrefixMapError {
50 alias: String,
51 local: String,
52 error: Box<PrefixMapError>,
53 },
54
55 #[error("No prefix map to dereference prefixed name {prefix}{local}")]
57 NoPrefixMapPrefixedName { prefix: String, local: String },
58
59 #[error(transparent)]
61 UnderefError(#[from] IriRefError),
62}