pub struct ErrorRouter { /* private fields */ }Expand description
The error router: classifies errors and dispatches to handler chains.
§Config Syntax
"TimeoutError:retry,warn,counter;.*:stop"- Error patterns (left of
:) are regex matched against the error name - Handler names (right of
:) are comma-separated, executed in chain order - Multiple rules are semicolon-separated
- If no pattern prefix,
.*(match all) is assumed
§Example
use nmbrs_errorhandler::ErrorRouter;
let router = ErrorRouter::parse("TimeoutError:retry,warn;.*:counter,stop").unwrap();Implementations§
Source§impl ErrorRouter
impl ErrorRouter
Sourcepub fn retry_verb_budget(&self) -> Option<u32>
pub fn retry_verb_budget(&self) -> Option<u32>
The retry budget implied by the spec’s retry / retry(N) verbs;
None when no rule carries a retry verb. See the field doc.
Sourcepub fn has_catch_all(&self) -> bool
pub fn has_catch_all(&self) -> bool
True when some rule carries the literal match-all pattern .*
(written explicitly, or implied by a pattern-less rule). An error
class matching NO rule falls through to stop with only an
eprintln — a router without a catch-all therefore has a silent
fall-through mode, which workload-load linting warns about. This
checks the pattern SOURCE, not regex universality: .* is the
one canonical way to write the catch-all.
Sourcepub fn default_stop() -> Self
pub fn default_stop() -> Self
Create a simple router with a default handler for all errors.
Sourcepub fn default_warn_count() -> Self
pub fn default_warn_count() -> Self
Create a router that warns and counts all errors.
Sourcepub fn handle_error(
&self,
error_name: &str,
error_msg: &str,
cycle: u64,
duration_nanos: u64,
) -> ErrorDetail
pub fn handle_error( &self, error_name: &str, error_msg: &str, cycle: u64, duration_nanos: u64, ) -> ErrorDetail
Handle an error: classify by name, dispatch through the matching handler chain, return the final ErrorDetail.