Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of sentry wrapping http.Client
// Non-confidential feedback for Posse
class SentryHttpClient extends BaseClient {
SentryHttpClient(this._inner);
final Client _inner;
@override
Future<StreamedResponse> send(BaseRequest request) async {
try {
return _inner.send(request);
} catch (error) {
final SentryResponse response = await sentryClient.capture(
event: new Event(
exception: error,
tags: {
'url': request.url.toString(),
'host': request.url.host,
'path': request.url.path,
},
),
);
if (!response.isSuccessful) {
print('Failed to report to Sentry.io: ${response.error}');
} else {
print('Successfully reported network failure');
}
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.