marine_core/host_imports/
errors.rs

1/*
2 * Copyright 2020 Fluence Labs Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17use super::WType;
18use super::WValue;
19
20use it_lilo::lifter::LiError;
21use it_lilo::lowerer::LoError;
22use it_lilo::traits::RecordResolvableError;
23use thiserror::Error as ThisError;
24
25#[derive(Debug, ThisError)]
26pub enum HostImportError {
27    /// An error occurred when host functions tries to lift IValues from WValues
28    /// and the latter has different type.
29    #[error(
30        "Expected {0} type, but found {1:?} value during interface values lifting from Wasm memory"
31    )]
32    MismatchWValues(WType, WValue),
33
34    /// An error occurred when a host functions tries to lift IValues from WValues
35    /// and the latter is not enough for that.
36    #[error("Not enough WValue arguments are provided from the Wasm side")]
37    MismatchWValuesCount,
38
39    #[error(transparent)]
40    LifterError(#[from] LiError),
41
42    #[error(transparent)]
43    LowererError(#[from] LoError),
44
45    #[error(transparent)]
46    RecordNotFound(#[from] RecordResolvableError),
47
48    #[error(transparent)]
49    InvalidUTF8String(#[from] std::string::FromUtf8Error),
50}