Skip to content

Instantly share code, notes, and snippets.

@collinjackson
Created August 25, 2017 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save collinjackson/4e57fe154786641e716fb7abcdc99fcf to your computer and use it in GitHub Desktop.
Save collinjackson/4e57fe154786641e716fb7abcdc99fcf to your computer and use it in GitHub Desktop.
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