pub struct HandlerError { /* private fields */ }Expand description
A handler processing failure, reported to the manager as a genErr Response.
Returned as the Err side of HandlerResult from
MibHandler::get and
MibHandler::get_next when the handler
failed to process the request — the backing store was unreachable, a lock
was poisoned, a hardware read timed out. It is distinct from the RFC 3416
exception values, which are successful answers about the MIB:
| Situation | Return |
|---|---|
| Object/instance doesn’t exist | Ok(GetResult::NoSuchObject / NoSuchInstance) |
| No more OIDs in the subtree | Ok(GetNextResult::EndOfMibView) |
| Couldn’t find out (backend failure) | Err(HandlerError) |
When a handler returns an error, the agent answers the whole request with
error-status genErr and error-index set to the failing variable binding
(RFC 3416 Section 4.2.1), for all protocol versions. The message and source
are logged by the agent; they are never sent on the wire — genErr carries
no detail.
§Construction
Any std::error::Error converts via ?, or build one from a message:
use async_snmp::handler::{HandlerError, HandlerResult, GetResult};
fn read_backend() -> std::io::Result<i32> {
Err(std::io::Error::other("device bus timeout"))
}
fn get_value() -> HandlerResult<GetResult> {
let raw = read_backend()?; // io::Error -> HandlerError
Ok(GetResult::Value(async_snmp::Value::Integer(raw)))
}
let err: HandlerError = HandlerError::new("cache poisoned");
assert_eq!(err.message(), "cache poisoned");
assert!(get_value().is_err());HandlerError intentionally does not implement std::error::Error:
that keeps the blanket From<E: std::error::Error> conversion (and with it
? on arbitrary error types) possible, the same trade-off anyhow::Error
makes. It is a terminal type — the agent consumes it; nothing converts out
of it.
Implementations§
Trait Implementations§
Source§impl Debug for HandlerError
impl Debug for HandlerError
Source§impl Display for HandlerError
impl Display for HandlerError
Auto Trait Implementations§
impl !RefUnwindSafe for HandlerError
impl !UnwindSafe for HandlerError
impl Freeze for HandlerError
impl Send for HandlerError
impl Sync for HandlerError
impl Unpin for HandlerError
impl UnsafeUnpin for HandlerError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more