ApplicationDiagnostics class final
High-level diagnostics orchestrator combining both:
1. Exception diagnoser discovery
2. Exception diagnosis reporting
This class acts as the central diagnostics engine of an application. It automatically:
- Discovers all available ExceptionDiagnosers
- Discovers all available ExceptionDiagnosisReporters
- Delegates exception analysis to diagnosers
- Forwards the resulting ExceptionDiagnosis to all reporters
ApplicationDiagnostics is therefore the runtime component responsible for
transforming raw exceptions into structured diagnostics and ensuring the
results are delivered to all registered reporting mechanisms.
π§ Construction
On instantiation, the constructor immediately:
- Calls
super.getDiagnosers()to load diagnosers discovered via reflection - Calls
super.getReporters()to load reporting sinks
This makes the diagnostics pipeline fully operational with zero manual setup.
π Diagnosis Flow
The pipeline operates as follows:
- An exception is sent to reportException
- Internally, diagnose iterates through all diagnosers
- The first diagnoser that returns a non-null ExceptionDiagnosis wins
- The diagnosis is then forwarded to all reporters via
report()
If:
- No diagnoser recognizes the exception, or
- No reporters are available
β¦then the exception is considered unhandled by the diagnostics system and
false is returned.
All internal errors are safely swallowed so that a faulty diagnoser or reporter cannot break the diagnostics pipeline.
Example
final diagnostics = ApplicationDiagnostics(context);
try {
throw InvalidConfigurationException("Missing file");
} catch (e) {
diagnostics.reportException(e);
}
This will automatically:
- Find a diagnoser capable of interpreting
InvalidConfigurationException - Generate a structured diagnosis
- Forward it to all registered reporters (file logs, telemetry, console, etc.)
- Implemented types
Constructors
- ApplicationDiagnostics(ConfigurableApplicationContext? context)
- High-level diagnostics orchestrator combining both:
Properties
- hashCode β int
-
The hash code for this object.
no setterinherited
- runtimeType β Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
diagnose(
Exception exception) β ExceptionDiagnosis? -
Attempts to produce an ExceptionDiagnosis for the given
exception. -
getDiagnosers(
) β List< ExceptionDiagnoser> -
Discovers and instantiates all available non-abstract subclasses of
ExceptionDiagnoser.
inherited
-
getReporters(
) β List< ExceptionDiagnosisReporter> -
Discovers and instantiates all non-abstract subclasses of
ExceptionDiagnosisReporter.
inherited
-
noSuchMethod(
Invocation invocation) β dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reportException(
Exception exception) β bool -
Reports the given
exceptionto the underlying exception-handling system.override -
toString(
) β String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) β bool -
The equality operator.
inherited