You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/dart/integrations/http-integration.mdx
+43-12Lines changed: 43 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,37 @@ description: "Learn more about the Sentry HTTP integration for the Dart SDK."
4
4
sidebar_order: 2
5
5
---
6
6
7
+
## Using the `SentryHttpClient` function
8
+
9
+
You can use the `SentryHttpClient` and call its methods directly, or you can use it with the [`runWithClient`](https://pub.dev/documentation/http/latest/http/runWithClient.html) function. If you need to use a fresh instance of the `client` (so that other instances are not affected) or to run in a separate [`Zone`](https://api.dart.dev/stable/3.5.0/dart-async/Zone-class.html), which allows you to override the functionality of the existing [`Zone`](https://api.dart.dev/stable/3.5.0/dart-async/Zone-class.html), then use the `runWithClient` function (see the `runWithClient` tab). Otherwise, just use `SentryHttpClient` directly and call its methods (see the `default` tab).
final response = await get(Uri.https('www.example.com', ''));
34
+
print(response.body);
35
+
}, () => sentryHttpClient);
36
+
```
37
+
7
38
## Reporting Bad HTTP Requests as Errors
8
39
9
40
The `SentryHttpClient` can also catch exceptions that may occur during requests — for example [`SocketException`](https://api.dart.dev/stable/2.13.4/dart-io/SocketException-class.html).
0 commit comments