1use std::path::PathBuf;
4
5use thiserror::Error;
6
7#[derive(Debug, Error)]
9#[non_exhaustive]
10pub enum ReadError {
11 #[error("RDF parse error")]
12 Rdf(#[from] sbol_rdf::ParseError),
13
14 #[error("failed to read `{path}`")]
15 Io {
16 path: PathBuf,
17 #[source]
18 source: std::io::Error,
19 },
20
21 #[error(
22 "unknown RDF format for `{path}` (extension: {})",
23 extension.as_deref().unwrap_or("<none>")
24 )]
25 UnknownFormat {
26 path: PathBuf,
27 extension: Option<String>,
28 },
29}
30
31#[derive(Clone, Debug, PartialEq, Eq, Error)]
38pub enum BuildError {
39 #[error(
40 "invalid SBOL displayId `{0}` — must start with a letter or underscore and contain only ASCII alphanumerics or underscores"
41 )]
42 InvalidDisplayId(String),
43
44 #[error("invalid SBOL namespace `{0}` — must be an http(s) URL with no trailing slash")]
45 InvalidNamespace(String),
46
47 #[error(
48 "invalid SBOL hash algorithm `{0}` — must be one of the spec-defined tokens (SHA1, SHA256, SHA3-256, ...)"
49 )]
50 InvalidHashAlgorithm(String),
51}
52
53#[derive(Debug, Error)]
55#[non_exhaustive]
56pub enum WriteError {
57 #[error("RDF write error")]
58 Rdf(#[from] sbol_rdf::WriteError),
59
60 #[error("failed to write `{path}`")]
61 Io {
62 path: PathBuf,
63 #[source]
64 source: std::io::Error,
65 },
66}