Skip to main content

hyperlight_common/func/
error.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025 The Hyperlight Authors.
3
4use alloc::string::String;
5
6use thiserror::Error;
7
8use crate::func::{ParameterValue, ReturnValue};
9
10/// The error type for Hyperlight operations
11#[derive(Error, Debug)]
12pub enum Error {
13    /// Failed to get value from parameter value
14    #[error("Failed To Convert Parameter Value {0:?} to {1:?}")]
15    ParameterValueConversionFailure(ParameterValue, &'static str),
16
17    /// Failed to get value from return value
18    #[error("Failed To Convert Return Value {0:?} to {1:?}")]
19    ReturnValueConversionFailure(ReturnValue, &'static str),
20
21    /// A function was called with an incorrect number of arguments
22    #[error("The number of arguments to the function is wrong: got {0:?} expected {1:?}")]
23    UnexpectedNoOfArguments(usize, usize),
24
25    /// The parameter value type is unexpected
26    #[error("The parameter value type is unexpected got {0:?} expected {1:?}")]
27    UnexpectedParameterValueType(ParameterValue, String),
28
29    /// The return value type is unexpected
30    #[error("The return value type is unexpected got {0:?} expected {1:?}")]
31    UnexpectedReturnValueType(ReturnValue, String),
32}