Recipes
Add bounded diagnostic context
Expose small technical facts through ErrorContextProvider without copying application state into reports.
v0.1.0-dev.1Intermediateark_error_manager
Add bounded diagnostic context
An ErrorContextProvider should expose facts needed to diagnose a class of failure, not a snapshot of the entire application.
dart
final class QueueContextProvider implements ErrorContextProvider {
const QueueContextProvider(this.queue);
final WorkQueue queue;
@override
ErrorContextSection collect(
ErrorOccurrence occurrence,
ErrorRuntimeEnvironment environment,
) => ErrorContextSection(
name: 'queue',
fields: <String, Object?>{
'pending': queue.pendingCount,
'capacity': queue.capacity,
},
);
}
Good context has bounded size, stable names, and a clear diagnostic purpose. Prefer counts, status codes, retry numbers, operation names, and non-personal correlation IDs.
Do not collect credentials, cookies, request bodies, route arguments, free-form user text, complete domain state, or opaque objects whose toString() output is uncontrolled.