zksync_error/error/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// AUTOGENERATED BASED ON A SET OF JSON FILES, DO NOT EDIT MANUALLY
//
pub(crate) mod definitions;
pub(crate) mod domains;
use crate::error::domains::AnvilZksync;
use crate::error::domains::Compiler;
use crate::error::domains::Core;
use crate::error::domains::Foundry;
use crate::error::domains::Hardhat;
use crate::error::domains::ZksyncError;
use crate::identifier::Identifier;
use std::error::Error;
pub trait IError<ContainedType>: Error
where
    ContainedType: Clone,
{
    fn get_identifier(&self) -> Identifier;
    fn get_message(&self) -> String;
    fn get_data(&self) -> ContainedType;
}
pub trait IUnifiedError<ContainedType>:
    serde::Serialize + for<'de> serde::Deserialize<'de> + IError<ContainedType>
where
    ContainedType: Clone,
{
}
pub trait ICustomError<U, C>
where
    U: IUnifiedError<C>,
    C: Clone,
{
    fn to_unified(&self) -> U;
}
pub trait CustomErrorMessage {
    fn get_message(&self) -> String;
}
pub trait NamedError {
    fn get_error_name(&self) -> String;
}
impl IError<ZksyncError> for ZksyncError {
    fn get_identifier(&self) -> Identifier {
        Identifier {
            kind: self.get_kind(),
            code: self.get_code(),
        }
    }
    fn get_message(&self) -> String {
        match self {
            ZksyncError::AnvilZksync(AnvilZksync::AnvilEnvironment(error)) => error.get_message(),
            ZksyncError::AnvilZksync(AnvilZksync::AnvilGeneric(error)) => error.get_message(),
            ZksyncError::AnvilZksync(AnvilZksync::Halt(error)) => error.get_message(),
            ZksyncError::AnvilZksync(AnvilZksync::Revert(error)) => error.get_message(),
            ZksyncError::Compiler(Compiler::LLVM_EVM(error)) => error.get_message(),
            ZksyncError::Compiler(Compiler::LLVM_Era(error)) => error.get_message(),
            ZksyncError::Compiler(Compiler::Solc(error)) => error.get_message(),
            ZksyncError::Compiler(Compiler::SolcFork(error)) => error.get_message(),
            ZksyncError::Compiler(Compiler::Zksolc(error)) => error.get_message(),
            ZksyncError::Compiler(Compiler::Zkvyper(error)) => error.get_message(),
            ZksyncError::Core(Core::API(error)) => error.get_message(),
            ZksyncError::Core(Core::EraVM(error)) => error.get_message(),
            ZksyncError::Core(Core::ExecutionPlatform(error)) => error.get_message(),
            ZksyncError::Core(Core::Sequencer(error)) => error.get_message(),
            ZksyncError::Foundry(Foundry::FoundryUpstream(error)) => error.get_message(),
            ZksyncError::Foundry(Foundry::FoundryZksync(error)) => error.get_message(),
            ZksyncError::Hardhat(Hardhat::HardhatUpstream(error)) => error.get_message(),
            ZksyncError::Hardhat(Hardhat::HardhatZksync(error)) => error.get_message(),
        }
    }
    fn get_data(&self) -> ZksyncError {
        self.clone()
    }
}