use thiserror::Error;
/// A result whose error is [`Error`](enum@Error).
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Debug)]
/// What went wrong starting a runtime, loading assemblies or calling into them.
pub enum Error {
/// A .NET install, framework, assembly, type or method wasn't found.
#[error("could not find {0}")]
NotFound(String),
/// A runtime library (`libcoreclr`, Mono) or one of its exports couldn't be
/// loaded; holds the library or export name and the loader's error.
#[error("could not load {0}: {1}")]
Library(String, libloading::Error),
/// A CoreCLR hosting call returned a failure `HRESULT`.
#[error("{function} failed with {code:#010x}")]
Host {
/// The CoreCLR hosting function that failed, e.g. `coreclr_initialize`.
function: &'static str,
/// The `HRESULT` it returned.
code: u32,
},
/// Reading a file, e.g. an assembly, failed.
#[error("io error: {0}")]
Io(#[from] std::io::Error),
/// Managed code threw; holds the exception's `ToString()` where it could be read.
#[error("managed exception: {0}")]
Managed(String),
/// Anything else the runtime reported, e.g. a failed Mono call or an
/// assembly hao couldn't read or write.
#[error("{0}")]
Other(String),
}