hyperlight_common/func/error.rs
1/*
2Copyright 2025 The Hyperlight Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17use alloc::string::String;
18
19use thiserror::Error;
20
21use crate::func::{ParameterValue, ReturnValue};
22
23/// The error type for Hyperlight operations
24#[derive(Error, Debug)]
25pub enum Error {
26 /// Failed to get value from parameter value
27 #[error("Failed To Convert Parameter Value {0:?} to {1:?}")]
28 ParameterValueConversionFailure(ParameterValue, &'static str),
29
30 /// Failed to get value from return value
31 #[error("Failed To Convert Return Value {0:?} to {1:?}")]
32 ReturnValueConversionFailure(ReturnValue, &'static str),
33
34 /// A function was called with an incorrect number of arguments
35 #[error("The number of arguments to the function is wrong: got {0:?} expected {1:?}")]
36 UnexpectedNoOfArguments(usize, usize),
37
38 /// The parameter value type is unexpected
39 #[error("The parameter value type is unexpected got {0:?} expected {1:?}")]
40 UnexpectedParameterValueType(ParameterValue, String),
41
42 /// The return value type is unexpected
43 #[error("The return value type is unexpected got {0:?} expected {1:?}")]
44 UnexpectedReturnValueType(ReturnValue, String),
45}