ExceptionDiagnosis class final
Represents a structured diagnostic report for an exception, providing human-readable context, optional recommended actions, and the originating exception itself.
ExceptionDiagnosis is typically produced by diagnostic or error-handling
components to enrich exceptions with:
- A descriptive explanation of what went wrong
- A suggested action or remediation step
- The underlying cause (the original Exception)
This class is immutable and safe to share across threads or async flows.
Example
try {
throw FormatException("Invalid configuration file");
} catch (e) {
final diagnosis = ExceptionDiagnosis(
cause: e,
description: "The provided configuration file could not be parsed.",
action: "Verify the file format or restore a valid configuration.",
);
print(diagnosis.getDescription());
}
Constructors
- ExceptionDiagnosis({required Exception cause, String? action, String? description})
- Represents a structured diagnostic report for an exception, providing human-readable context, optional recommended actions, and the originating exception itself.
Properties
- action → String?
-
An optional recommended action or remediation guidance for resolving the
diagnosed issue.
final
- cause → Exception
-
The underlying exception that triggered this diagnosis.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getDescription(
) → String - Returns the human-readable diagnostic description.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited