Recipes
Report an intentionally handled error
Preserve application-level diagnostics when a local integration boundary must consume a caught exception.
v0.1.0-dev.1Intermediateark_error_manager
Report an intentionally handled error
A root boundary cannot observe an error that local code catches and consumes. Report it explicitly only when the boundary must return a fallback result and the incident still needs an application-level decision.
dart
try {
await externalClient.synchronize();
} catch (error, stackTrace) {
await manager.handleError(
error,
stackTrace,
source: ErrorCaptureSource.reported,
operation: 'externalClient.synchronize',
);
return const SynchronizationResult.unavailable();
}
Use handleError when the caller must wait for processing. Use captureError when scheduling is sufficient.
Avoid three failure modes:
- submitting the error and then rethrowing it into another configured root boundary;
- wrapping every feature method in reporting code;
- converting an expected business outcome into a global incident.