hao_runtime/error.rs
1use thiserror::Error;
2
3/// A result whose error is [`Error`](enum@Error).
4pub type Result<T> = std::result::Result<T, Error>;
5
6#[derive(Error, Debug)]
7/// What went wrong starting a runtime, loading assemblies or calling into them.
8pub enum Error {
9 /// A .NET install, framework, assembly, type or method wasn't found.
10 #[error("could not find {0}")]
11 NotFound(String),
12 /// A runtime library (`libcoreclr`, Mono) or one of its exports couldn't be
13 /// loaded; holds the library or export name and the loader's error.
14 #[error("could not load {0}: {1}")]
15 Library(String, libloading::Error),
16 /// A CoreCLR hosting call returned a failure `HRESULT`.
17 #[error("{function} failed with {code:#010x}")]
18 Host {
19 /// The CoreCLR hosting function that failed, e.g. `coreclr_initialize`.
20 function: &'static str,
21 /// The `HRESULT` it returned.
22 code: u32,
23 },
24 /// Reading a file, e.g. an assembly, failed.
25 #[error("io error: {0}")]
26 Io(#[from] std::io::Error),
27 /// Managed code threw; holds the exception's `ToString()` where it could be read.
28 #[error("managed exception: {0}")]
29 Managed(String),
30 /// Anything else the runtime reported, e.g. a failed Mono call or an
31 /// assembly hao couldn't read or write.
32 #[error("{0}")]
33 Other(String),
34}