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
74
75
76
77
78
79
80
81
use proptest;
use std::borrow::Cow;
use std::fmt;
#[derive(Debug, PartialEq, Fail)]
pub enum Error {
#[fail(display = "no object item to link named `{}`", item)]
NoLinkerItem { item: String },
#[fail(display = "no object path to link named `{}`", path)]
NoLinkerPath { path: String },
#[fail(display = "bad input at position `{}`: {}", position, message)]
BadInputPos {
position: usize,
message: Cow<'static, str>,
},
#[fail(display = "call error: {}", message)]
Call { message: String },
#[fail(display = "{}", message)]
Other { message: String },
}
impl From<&'static str> for Error {
fn from(value: &'static str) -> Self {
Error::Other {
message: value.to_string(),
}
}
}
impl From<String> for Error {
fn from(value: String) -> Self {
Error::Other { message: value }
}
}
impl From<fmt::Error> for Error {
fn from(error: fmt::Error) -> Self {
Error::Other {
message: error.to_string(),
}
}
}
pub struct DecodingError;
impl From<DecodingError> for Error {
fn from(_: DecodingError) -> Self {
Error::Other {
message: "failed to decode input".to_string(),
}
}
}
impl From<Error> for proptest::test_runner::TestCaseError {
fn from(error: Error) -> proptest::test_runner::TestCaseError {
proptest::test_runner::TestCaseError::Fail(error.to_string().into())
}
}
pub struct NonceError;
impl From<NonceError> for Error {
fn from(_: NonceError) -> Self {
Error::Other {
message: "failed to construct nonce".to_string(),
}
}
}
pub struct BalanceError;
impl From<BalanceError> for Error {
fn from(_: BalanceError) -> Self {
Error::Other {
message: "failed to get balance".to_string(),
}
}
}