fce_module_info_parser/manifest/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 semver::SemVerError;
18use thiserror::Error as ThisError;
19use std::str::Utf8Error;
20
21#[derive(Debug, ThisError, PartialEq)]
22pub enum ManifestError {
23 /// Manifest of a Wasm file doesn't have enough bytes to read size of a field from its prefix.
24 #[error(
25 "{0} can't be read: embedded manifest doesn't contain enough bytes to read field size from prefix"
26 )]
27 NotEnoughBytesForPrefix(&'static str),
28
29 /// Manifest of a Wasm file doesn't have enough bytes to read a field.
30 #[error(
31 "{0} can't be read: embedded manifest doesn't contain enough bytes to read field of size {1}"
32 )]
33 NotEnoughBytesForField(&'static str, usize),
34
35 /// Manifest of a Wasm file doesn't have enough bytes to read field.
36 #[error("{0} is an invalid Utf8 string: {1}")]
37 FieldNotValidUtf8(&'static str, Utf8Error),
38
39 /// Size inside prefix of a field is too big (it exceeds usize or overflows with prefix size).
40 #[error("{0} has too big size: {1}")]
41 TooBigFieldSize(&'static str, u64),
42
43 /// Version can't be parsed with semver.
44 #[error("embedded to the Wasm file version is corrupted: '{0}'")]
45 ModuleVersionCorrupted(#[from] SemVerError),
46
47 /// Manifest contains some trailing characters.
48 #[error("embedded manifest is corrupted: there are some trailing characters")]
49 ManifestRemainderNotEmpty,
50
51 /// Error occurred while parsing embedded build time.
52 #[error("build time can't be parsed: {0}")]
53 DateTimeParseError(#[from] chrono::ParseError),
54}