providerDidFail method
void
providerDidFail(
- ProviderBase<
Object?> provider, - Object error,
- StackTrace stackTrace,
- ProviderContainer container,
A provider emitted an error, be it by throwing during initialization or by having a Future/Stream emit an error
Implementation
@override
void providerDidFail(
ProviderBase<Object?> provider,
Object error,
StackTrace stackTrace,
ProviderContainer container,
) {
assert(() {
final context = CausalityZone.currentContext();
TrinityEventBus.instance.emit(CausalEvent(
parentId: context?.eventId,
type: CausalEventType.crashEvent,
description: 'Riverpod: ${provider.name ?? provider.runtimeType} error',
metadata: {
'provider_name': provider.name ?? 'unnamed',
'provider_type': provider.runtimeType.toString(),
'error_type': error.runtimeType.toString(),
'error_message': error.toString().substring(
0,
error.toString().length > 500 ? 500 : error.toString().length,
),
'stack_top_3': stackTrace.toString().split('\n').take(3).join('\n'),
'action': 'error',
},
));
return true;
}());
}