bulwark_wasm_host/
errors.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/// Returned when an attempt to load a plugin fails.
#[derive(thiserror::Error, Debug)]
pub enum PluginLoadError {
    #[error(transparent)]
    WasiError(#[from] wasi_common::Error),
    #[error(transparent)]
    StringArray(#[from] wasi_common::StringArrayError),
    #[error(transparent)]
    Resolution(#[from] bulwark_config::ResolutionError),
    #[error("at least one resource required")]
    ResourceMissing,
    #[error(transparent)]
    AnyError(#[from] anyhow::Error),
}

/// Returned when an attempt to instantiate a plugin fails.
#[derive(thiserror::Error, Debug)]
pub enum PluginInstantiationError {
    #[error(transparent)]
    WasiError(#[from] wasi_common::Error),
    #[error(transparent)]
    StringArray(#[from] wasi_common::StringArrayError),
    #[error(transparent)]
    ContextInstantiation(#[from] ContextInstantiationError),
    #[error(transparent)]
    AnyError(#[from] anyhow::Error),
}

/// Returned when an attempt to execute a function within a plugin environment fails.
#[derive(thiserror::Error, Debug)]
pub enum PluginExecutionError {
    #[error(transparent)]
    WasiError(#[from] wasi_common::Error),
    #[error(transparent)]
    StringArray(#[from] wasi_common::StringArrayError),
    #[error("function not implemented '{expected}'")]
    NotImplementedError { expected: String },
    #[error(transparent)]
    AnyError(#[from] anyhow::Error),
}

/// Returned when attempting to create a [`RequestContext`](crate::RequestContext) fails.
#[derive(thiserror::Error, Debug)]
pub enum ContextInstantiationError {
    #[error(transparent)]
    StringArray(#[from] wasi_common::StringArrayError),
    #[error(transparent)]
    ConfigSerialization(#[from] bulwark_config::ConfigSerializationError),
    #[error(transparent)]
    AnyError(#[from] anyhow::Error),
}