---
title: "Usage"
description: "Use the SDK to manually capture errors and other events."
url: https://docs.sentry.io/platforms/dart/usage/
---

# Usage | Sentry for Dart

Sentry's SDK hooks into your runtime environment and automatically reports errors, uncaught exceptions, and unhandled rejections as well as other types of errors depending on the platform.

Key terms:

* An *event* is one instance of sending data to Sentry. Generally, this data is an error or exception.
* An *issue* is a grouping of similar events.
* The reporting of an event is called *capturing*. When an event is captured, it’s sent to Sentry.

The most common form of capturing is to capture errors. What can be captured as an error varies by platform. In general, if you have something that looks like an exception, it can be captured. For some SDKs, you can also omit the argument to `captureException` and Sentry will attempt to capture the current exception. It is also useful for manual reporting of errors or messages to Sentry.

While capturing an event, you can also record the breadcrumbs that lead up to that event. Breadcrumbs are different from events: they will not create an event in Sentry, but will be buffered until the next event is sent. Learn more about breadcrumbs in our [Breadcrumbs documentation](https://docs.sentry.io/platforms/dart/enriching-events/breadcrumbs.md).

## [Capturing Errors](https://docs.sentry.io/platforms/dart/usage.md#capturing-errors)

In Dart you can capture any exception object that you caught:

```dart
import 'package:sentry/sentry.dart';

try {
  throw StateError('Sentry Test Exception');
} catch (exception, stackTrace) {
  await Sentry.captureException(
    exception,
    stackTrace: stackTrace,
  );
}
```

## [Tips for Catching Errors](https://docs.sentry.io/platforms/dart/usage.md#tips-for-catching-errors)

* Use a `try/catch` block
* Use a `catchError` block for `Futures`
* `Isolate` errors on the `current` Isolate which is the equivalent of a main/UI thread, e.g. using `Isolate.current.addErrorListener`, are captured automatically (Only for non-Web Apps).
* Add an [Error Listener](https://api.flutter.dev/flutter/dart-isolate/Isolate/addErrorListener.html) to your `Isolates` argument by calling `isolate.addSentryErrorListener()`.
* Use `await` when calling `Sentry.captureMessage` or `Sentry.captureException`. Alternatively, you can pass the `stackTrace` parameter via `Sentry.captureException(exception, stackTrace: stackTrace)` to get the correct stack trace.

## [Capturing Messages](https://docs.sentry.io/platforms/dart/usage.md#capturing-messages)

Another common operation is to capture a bare message. A message is textual information that should be sent to Sentry. Typically, our SDKs don't automatically capture messages, but you can capture them manually.

Messages show up as issues on your issue stream, with the message as the issue name.

```dart
import 'package:sentry/sentry.dart';

await Sentry.captureMessage('Something went wrong');
```

## Pages in this section

- [Set the Level](https://docs.sentry.io/platforms/dart/usage/set-level.md)
- [SDK Fingerprinting](https://docs.sentry.io/platforms/dart/usage/sdk-fingerprinting.md)
