pub struct DiagnosticReport { /* private fields */ }Implementations§
Source§impl DiagnosticReport
impl DiagnosticReport
pub fn reason(&self) -> &str
pub fn detail(&self) -> Option<&str>
pub fn position(&self) -> Option<&str>
pub fn context(&self) -> &[OperationContext]
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Render this report as a human-readable diagnostic string.
§Example
use orion_error::{StructError, UnifiedReason};
let err = StructError::from(UnifiedReason::validation_error())
.with_detail("field `email` is required");
let report = err.report();
let output = report.render();
assert!(output.contains("reason:"));
assert!(output.contains("validation"));Sourcepub fn redacted(&self, policy: &impl RedactPolicy) -> Self
pub fn redacted(&self, policy: &impl RedactPolicy) -> Self
Return a redacted copy of this report.
§Example
use orion_error::{StructError, UnifiedReason};
use orion_error::report::RedactPolicy;
struct HidePosition;
impl RedactPolicy for HidePosition {
fn redact_value(&self, key: Option<&str>, value: &str) -> Option<String> {
if key == Some("position") {
Some("<hidden>".to_string())
} else {
Some(value.to_string())
}
}
}
let report = StructError::from(UnifiedReason::validation_error())
.with_position("src/main.rs:42")
.report()
.redacted(&HidePosition);
assert_eq!(report.position(), Some("<hidden>"));Sourcepub fn render_redacted(&self, policy: &impl RedactPolicy) -> String
pub fn render_redacted(&self, policy: &impl RedactPolicy) -> String
Render this report after applying redaction.
§Example
use orion_error::{StructError, UnifiedReason};
use orion_error::report::RedactPolicy;
struct HideDetail;
impl RedactPolicy for HideDetail {
fn redact_value(&self, key: Option<&str>, value: &str) -> Option<String> {
if key == Some("detail") {
Some("<redacted>".to_string())
} else {
Some(value.to_string())
}
}
}
let rendered = StructError::from(UnifiedReason::validation_error())
.with_detail("token=abc")
.report()
.render_redacted(&HideDetail);
assert!(rendered.contains("detail: <redacted>"));Trait Implementations§
Source§impl Clone for DiagnosticReport
impl Clone for DiagnosticReport
Source§fn clone(&self) -> DiagnosticReport
fn clone(&self) -> DiagnosticReport
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DiagnosticReport
impl Debug for DiagnosticReport
Source§impl<T: DomainReason> From<&StructError<T>> for DiagnosticReport
impl<T: DomainReason> From<&StructError<T>> for DiagnosticReport
Source§fn from(value: &StructError<T>) -> Self
fn from(value: &StructError<T>) -> Self
Converts to this type from the input type.
Source§impl<T: DomainReason> From<StructError<T>> for DiagnosticReport
impl<T: DomainReason> From<StructError<T>> for DiagnosticReport
Source§fn from(value: StructError<T>) -> Self
fn from(value: StructError<T>) -> Self
Converts to this type from the input type.
Source§impl PartialEq for DiagnosticReport
impl PartialEq for DiagnosticReport
impl StructuralPartialEq for DiagnosticReport
Auto Trait Implementations§
impl Freeze for DiagnosticReport
impl RefUnwindSafe for DiagnosticReport
impl Send for DiagnosticReport
impl Sync for DiagnosticReport
impl Unpin for DiagnosticReport
impl UnsafeUnpin for DiagnosticReport
impl UnwindSafe for DiagnosticReport
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
Mutably borrows from an owned value. Read more