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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/// A macro that applies a callback macro to all `Report` builder methods.
macro_rules! for_each_report_builder_method {
($callback:ident) => {
$callback! {
/// Adds a business context key-value pair to the report.
fn with_ctx(key: impl Into<crate::StaticRefStr>, value: impl Into<crate::report::ContextValue>) -> Self
}
$callback! {
/// Adds a system context key-value pair to the report.
fn with_system(key: impl Into<crate::StaticRefStr>, value: impl Into<crate::report::ContextValue>) -> Self
}
$callback! {
/// Replaces the system context for the report.
fn set_system(system: crate::report::ContextMap) -> Self
}
$callback! {
/// Replaces the business context for the report.
fn set_ctx(ctx: crate::report::ContextMap) -> Self
}
$callback! {
/// Attaches a printable note to the report.
fn attach_printable(message: impl core::fmt::Display + Send + Sync + 'static) -> Self
}
$callback! {
/// Attaches a payload with an optional media type to the report.
fn attach_payload(
name: impl Into<crate::StaticRefStr>,
value: impl Into<crate::report::AttachmentValue>,
media_type: Option<impl Into<crate::StaticRefStr>>
) -> Self
}
$callback! {
/// Adds a note to the report (alias for `attach_printable`).
fn attach_note(message: impl core::fmt::Display + Send + Sync + 'static) -> Self
}
$callback! {
/// Sets the metadata for the report.
fn with_metadata(metadata: crate::report::ReportMetadata<State>) -> Self
}
$callback! {
/// Sets the error code for the report, replacing any existing value.
fn set_error_code(error_code: impl Into<crate::report::ErrorCode>) -> Self
}
$callback! {
/// Sets the error code only if not already set.
fn with_error_code(error_code: impl Into<crate::report::ErrorCode>) -> Self
}
$callback! {
/// Sets the category for the report, replacing any existing value.
fn set_category(category: impl Into<crate::StaticRefStr>) -> Self
}
$callback! {
/// Sets the category only if not already set.
fn with_category(category: impl Into<crate::StaticRefStr>) -> Self
}
$callback! {
/// Sets whether the error is retryable, replacing any existing value.
fn set_retryable(retryable: bool) -> Self
}
$callback! {
/// Sets whether the error is retryable only if not already set.
fn with_retryable(retryable: bool) -> Self
}
$callback! {
/// Sets the stack trace for the report, replacing any existing value.
fn set_stack_trace(stack_trace: crate::report::StackTrace) -> Self
}
$callback! {
/// Sets the stack trace only if not already present.
fn with_stack_trace(stack_trace: crate::report::StackTrace) -> Self
}
$callback! {
/// Clears the stack trace from the report.
fn clear_stack_trace() -> Self
}
#[cfg(feature = "std")]
$callback! {
/// Captures the stack trace for the report if not already present.
fn capture_stack_trace() -> Self
}
#[cfg(feature = "std")]
$callback! {
/// Forcefully captures the stack trace for the report.
fn force_capture_stack() -> Self
}
$callback! {
/// Adds a display cause to the report.
fn with_display_cause(cause: impl core::fmt::Display + Send + Sync + 'static) -> Self
}
$callback! {
/// Adds multiple display causes to the report.
fn with_display_causes<I, C>(causes: I) -> Self
where
I: IntoIterator<Item = C>,
C: core::fmt::Display + Send + Sync + 'static
}
$callback! {
/// Replaces the display-cause chain for the report.
fn set_display_causes(display_causes: crate::report::DisplayCauseChain) -> Self
}
$callback! {
/// Adds an error source to the report's diagnostic source chain.
fn with_diag_src_err(err: impl core::error::Error + Send + Sync + 'static) -> Self
}
$callback! {
/// Replaces the diagnostic source-error chain for the report.
fn set_diag_src_errs(source_errors: crate::report::SourceErrorChain) -> Self
}
$callback! {
/// Sets the report options for this report.
fn set_options(options: crate::report::ReportOptions) -> Self
}
$callback! {
/// Sets whether source chains should be accumulated during `map_err()`.
fn set_accumulate_src_chain(accumulate: bool) -> Self
}
$callback! {
/// Sets the severity for the report, transitioning to `HasSeverity` typestate.
fn set_severity(severity: crate::report::Severity) -> Result<T, crate::report::Report<E, crate::report::HasSeverity>> [STATE_CHANGE]
}
$callback! {
/// Sets the severity only if not already set, transitioning to `HasSeverity` typestate.
fn with_severity(severity: crate::report::Severity) -> Result<T, crate::report::Report<E, crate::report::HasSeverity>> [STATE_CHANGE]
}
};
}