weirdnet_ext/error.rs
1/// Errors from the extension host.
2#[derive(Debug, thiserror::Error)]
3pub enum Error {
4 /// A package or manifest is malformed.
5 #[error("invalid package: {0}")]
6 Invalid(String),
7 /// A signature or file hash does not check out.
8 #[error("verification failed: {0}")]
9 Verify(String),
10 /// An update is signed by another author than the installed version.
11 #[error("{id} is pinned to another author ({pinned}); this package is signed by {got}")]
12 AuthorChanged {
13 /// The extension id.
14 id: String,
15 /// The pinned author's user id.
16 pinned: String,
17 /// The package author's user id.
18 got: String,
19 },
20 /// An update is not newer than what is installed.
21 #[error("{id} {have} is installed; {got} is not newer")]
22 NotNewer {
23 /// The extension id.
24 id: String,
25 /// Installed version.
26 have: String,
27 /// Package version.
28 got: String,
29 },
30 /// The sandbox can't be set up (or isn't available and was required).
31 #[error("sandbox: {0}")]
32 Sandbox(String),
33 /// Native extensions can't run here.
34 #[error("unsupported: {0}")]
35 Unsupported(String),
36 /// Spawning or supervising a process failed.
37 #[error("process: {0}")]
38 Process(String),
39 /// An I/O error.
40 #[error(transparent)]
41 Io(#[from] std::io::Error),
42}
43
44/// `Result` with [`Error`].
45pub type Result<T, E = Error> = std::result::Result<T, E>;
46
47pub(crate) fn invalid(m: impl Into<String>) -> Error {
48 Error::Invalid(m.into())
49}