Enum avalanche_types::errors::Error
source · pub enum Error {
API {
message: String,
is_retryable: bool,
},
Other {
message: String,
is_retryable: bool,
},
}
Expand description
Backing errors for all consensus operations.
Variants§
Implementations§
source§impl Error
impl Error
sourcepub fn message(&self) -> String
pub fn message(&self) -> String
Returns the error message in “String”.
Examples found in repository?
src/errors.rs (line 39)
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
pub fn contains(&self, s: &str) -> bool {
self.message().contains(s)
}
}
#[derive(Debug)]
pub struct Errors {
d: Rc<RefCell<Vec<Error>>>,
}
impl Errors {
pub fn new() -> Self {
Self {
d: Rc::new(RefCell::new(Vec::new())),
}
}
pub fn errored(&self) -> bool {
!self.d.borrow().is_empty()
}
pub fn add(&self, e: Error) {
self.d.borrow_mut().push(e);
}
}
impl Default for Errors {
fn default() -> Self {
Self::new()
}
}
/// ref. <https://doc.rust-lang.org/std/string/trait.ToString.html>
/// ref. <https://doc.rust-lang.org/std/fmt/trait.Display.html>
/// Use "Self.to_string()" to directly invoke this
impl fmt::Display for Errors {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut errs: Vec<String> = Vec::new();
for e in self.d.borrow().iter() {
errs.push(e.message());
}
write!(f, "{}", errs.join(", "))
}
sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns if the error is retryable.
Trait Implementations§
source§impl Error for Error
impl Error for Error
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnwindSafe for Error
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request