1
0
mirror of https://github.com/fluencelabs/marine.git synced 2025-04-12 10:26:03 +00:00

75 lines
2.6 KiB
Rust
Raw Normal View History

2020-06-04 12:46:12 +03:00
/*
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2021-05-20 20:20:57 +03:00
use marine_module_interface::interface::InterfaceError;
use marine_module_interface::it_interface::ITInterfaceError;
2021-05-10 12:51:22 +03:00
use wasmer_it::decoders::wat::Error as WATError;
2021-03-12 20:04:47 +03:00
use thiserror::Error as ThisError;
2020-06-04 12:46:12 +03:00
2021-03-12 20:04:47 +03:00
use std::io::Error as IOError;
#[derive(Debug, ThisError)]
2021-05-10 12:51:22 +03:00
pub enum ITParserError {
/// IT section is absent.
2021-03-12 20:04:47 +03:00
#[error("the module doesn't contain IT section")]
NoITSection,
2020-06-04 12:46:12 +03:00
2021-05-10 12:51:22 +03:00
/// Multiple IT sections.
2021-03-12 20:04:47 +03:00
#[error("the module contains multiple IT sections that is unsupported")]
MultipleITSections,
2020-06-04 12:46:12 +03:00
2021-05-10 12:51:22 +03:00
/// IT section remainder isn't empty.
2021-03-12 20:04:47 +03:00
#[error("IT section is corrupted: IT section remainder isn't empty")]
ITRemainderNotEmpty,
2020-06-04 12:46:12 +03:00
2021-05-10 12:51:22 +03:00
/// An error occurred while parsing IT section.
#[error(
"IT section is corrupted: {0}.\
2021-05-10 12:51:22 +03:00
\nProbably the module was compiled with an old version of marine cli, please try to update and recompile.\
2021-05-11 15:44:11 +03:00
\nTo update marine run: cargo install marine --force"
)]
CorruptedITSection(nom::Err<(Vec<u8>, nom::error::ErrorKind)>),
2020-06-04 12:46:12 +03:00
2021-05-10 12:51:22 +03:00
/// An error related to incorrect data in IT section.
2021-03-12 20:04:47 +03:00
#[error("{0}")]
IncorrectITFormat(String),
2021-05-20 20:20:57 +03:00
/// An error occurred while processing module interface.
#[error("{0}")]
ModuleInterfaceError(#[from] InterfaceError),
/// An error occurred while processing module IT interface.
#[error("{0}")]
ModuleITInterfaceError(#[from] ITInterfaceError),
2020-06-04 12:46:12 +03:00
/// An error occurred while parsing file in Wat format.
2021-03-12 20:04:47 +03:00
#[error("provided file with IT definitions is corrupted: {0}")]
CorruptedITFile(#[from] WATError),
2020-06-04 12:46:12 +03:00
2021-03-12 20:04:47 +03:00
/// An error occurred while parsing Wasm file.
#[error("provided Wasm file is corrupted: {0}")]
2020-06-04 12:46:12 +03:00
CorruptedWasmFile(anyhow::Error),
/// An error occurred while manipulating with converting ast to bytes.
2021-03-12 20:04:47 +03:00
#[error("Convertation Wast to AST failed with: {0}")]
AstToBytesError(#[from] IOError),
2020-06-04 12:46:12 +03:00
2021-03-12 20:04:47 +03:00
/// Wasm emitting file error.
#[error("Emitting resulted Wasm file failed with: {0}")]
2020-06-04 12:46:12 +03:00
WasmEmitError(anyhow::Error),
}