radix_wasmi/func/
error.rs

1use core::{fmt, fmt::Display};
2
3/// Errors that can occur upon type checking function signatures.
4#[derive(Debug)]
5pub enum FuncError {
6    /// The exported function could not be found.
7    ExportedFuncNotFound,
8    /// A function parameter did not match the required type.
9    MismatchingParameterType,
10    /// Specified an incorrect number of parameters.
11    MismatchingParameterLen,
12    /// A function result did not match the required type.
13    MismatchingResultType,
14    /// Specified an incorrect number of results.
15    MismatchingResultLen,
16}
17
18impl Display for FuncError {
19    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20        match self {
21            FuncError::ExportedFuncNotFound => {
22                write!(f, "could not find exported function")
23            }
24            FuncError::MismatchingParameterType => {
25                write!(f, "encountered incorrect function parameter type")
26            }
27            FuncError::MismatchingParameterLen => {
28                write!(f, "encountered an incorrect number of parameters")
29            }
30            FuncError::MismatchingResultType => {
31                write!(f, "encountered incorrect function result type")
32            }
33            FuncError::MismatchingResultLen => {
34                write!(f, "encountered an incorrect number of results")
35            }
36        }
37    }
38}