Skip to main content

haste_fhir_package/
error.rs

1use haste_fhir_operation_error::derive::OperationOutcomeError;
2
3/// Why a package could not be read or fetched.
4#[derive(OperationOutcomeError, Debug)]
5pub enum PackageError {
6    #[error(
7        code = "invalid",
8        diagnostic = "'{arg0}' is not a valid package name. Names use letters, digits, '.', '-' and '_'."
9    )]
10    InvalidName(String),
11
12    #[error(
13        code = "invalid",
14        diagnostic = "'{arg0}' is not a valid package version."
15    )]
16    InvalidVersion(String),
17
18    #[error(code = "invalid", diagnostic = "The package could not be read: {arg0}")]
19    Unreadable(String),
20
21    #[error(
22        code = "invalid",
23        diagnostic = "The package has no package.json, so it is not a FHIR package."
24    )]
25    MissingManifest,
26
27    #[error(
28        code = "invalid",
29        diagnostic = "The package's package.json is invalid: {arg0}"
30    )]
31    InvalidManifest(String),
32
33    #[error(
34        code = "too-costly",
35        diagnostic = "The package is larger than the {arg0} byte limit."
36    )]
37    TooLarge(u64),
38
39    #[error(
40        code = "too-costly",
41        diagnostic = "The package unpacks to more than {arg0} bytes."
42    )]
43    TooLargeUnpacked(u64),
44
45    #[error(
46        code = "too-costly",
47        diagnostic = "The package has more than {arg0} files."
48    )]
49    TooManyFiles(usize),
50
51    #[error(
52        code = "not-found",
53        diagnostic = "Package '{arg0}' was not found in the package registry."
54    )]
55    NotFound(String),
56
57    #[error(
58        code = "not-found",
59        diagnostic = "No published version of '{arg0}' matches '{arg1}'."
60    )]
61    NoMatchingVersion(String, String),
62
63    #[error(
64        code = "transient",
65        diagnostic = "The package registry could not be reached: {arg0}"
66    )]
67    Registry(String),
68
69    #[error(
70        code = "not-supported",
71        diagnostic = "This server does not fetch packages from a registry. Upload the package instead."
72    )]
73    RegistryDisabled,
74
75    #[error(
76        code = "exception",
77        diagnostic = "The server's package registry setting (packages.registry_url) is not an https URL."
78    )]
79    InvalidRegistry,
80}