onError method
Called when an exception was occurred during the request.
Implementation
@override
void onError(DioException err, ErrorInterceptorHandler handler) {
assert(() {
final parentId = err.requestOptions.extra['_trinity_event_id'] as String?;
TrinityEventBus.instance.emit(CausalEvent(
parentId: parentId,
type: CausalEventType.networkEvent,
description: 'HTTP ERROR ${err.requestOptions.method} '
'${err.requestOptions.uri.path}',
metadata: {
'method': err.requestOptions.method,
'url': err.requestOptions.uri.toString(),
'path': err.requestOptions.uri.path,
'phase': 'error',
'error_type': err.type.name,
'error_message': err.message ?? 'unknown',
'status_code': err.response?.statusCode ?? 0,
},
));
return true;
}());
handler.next(err);
}