Skip to main content

iri_s/
error.rs

1use crate::iri::IriS;
2use serde::Serialize;
3use thiserror::Error;
4
5/// Errors that can occur when working with [`IriS`]
6#[derive(Error, Debug, Clone, Serialize)]
7pub enum IriSError {
8    /// Error converting a [`std::path::Path`] into an IRI
9    #[error("Error converting path {path} to IRI: {error}")]
10    ConvertingPathToIri { path: String, error: String },
11
12    /// Error parsing an [`String`] into an IRI
13    #[error("Error parsing {str} as IRI: {error}")]
14    IriParseError { str: String, error: String },
15
16    /// Error parsing an [`String`] into an IRI using a base IRI
17    #[error("Parsing {str} using base: {base} as IRI. Error: {error}")]
18    IriParseErrorWithBase { str: String, base: String, error: String },
19
20    /// Error resolving an IRI against a base IRI
21    #[error("Error resolving IRI `{other}` with base IRI `{base}`: {error}")]
22    IriResolveError {
23        error: String,
24        base: Box<IriS>,
25        other: String,
26    },
27
28    /// Error joining an IRI with a [`String`]
29    #[error("Error joining IRI `{current}` with `{str}`: {error}")]
30    JoinError {
31        error: String,
32        current: Box<IriS>,
33        str: String,
34    },
35
36    /// Error creating a [`reqwest`] HTTP client
37    #[error("Creating reqwest http client: {error}")]
38    ReqwestClientCreation { error: String },
39
40    /// Error parsing an IRI as a [`url::Url`]
41    #[error("Parsing Iri {str} as Url. Error: {error}")]
42    UrlParseError { str: String, error: String },
43
44    /// Error performing an HTTP request with [`reqwest`]
45    #[error("Http request error: {error}")]
46    ReqwestError { error: String },
47
48    /// Error performing an HTTP request with [`reqwest`] and obtaining the response as text
49    #[error("Http request error as String: {error}")]
50    ReqwestTextError { error: String },
51
52    /// Error converting a file scheme [`url::Url`] into a [`std::path::Path`]
53    #[error("trying to obtain a path from file scheme Url: {url}")]
54    ConvertingFileUrlToPath { url: String },
55
56    /// Error reading from a file obtained from a [`url::Url`]
57    #[error("Error reading from file {path} obtained from url {url}. Error: {error}")]
58    IOErrorFile { path: String, url: String, error: String },
59
60    #[error("Error parsing Turtle string `{str}` as IRI: {error}")]
61    TurtleParseError { str: String, error: String },
62}