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

# Usage | Sentry for Unity

Sentry's SDK hooks into the game engine and automatically reports errors, uncaught exceptions, 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.

By default, the Sentry Unity SDK automatically captures errors through Unity's logging system. For details on this see the [Automatic Error Capture documentation](https://docs.sentry.io/platforms/unity/usage/automatic-error-capture.md).

In addition to automatic capture, you can manually capture errors, exceptions, and messages as described below.

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

The most common form of capturing is to capture errors. In Unity C# code, you can use `SentrySdk.CaptureException(exception)` to explicitly report exceptions and mark them as `handled`.

```csharp
try
{
    AFunctionThatMightFail();
}
catch (Exception e)
{
    SentrySdk.CaptureException(e);
}
```

While capturing an event, these get also recorded as breadcrumbs that lead up to the next 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/unity/enriching-events/breadcrumbs.md).

### [Ignoring Errors](https://docs.sentry.io/platforms/unity/usage.md#ignoring-errors)

You can ignore exceptions by their type when initializing the SDK:

```csharp
// Add this to the SDK initialization callback
options.AddExceptionFilterForType<OperationCanceledException>();
```

This modifies the behavior of the [entire inheritance chain](https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/inheritance#background-what-is-inheritance). As a result, the example code will also filter out `TaskCanceledException` since it is derived from `OperationCanceledException`.

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

Another common operation is to capture a bare message. A message is textual information that should be sent to Sentry. The SDK will [automatically capture messages](https://docs.sentry.io/platforms/unity/usage/automatic-error-capture.md) created through `Debug.LogError()`. You can opt out of this behaviour on the `Logging` tab in the editor (Tools->Sentry).

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

```csharp
SentrySdk.CaptureMessage("Something went wrong");
```

By default, the SDK only provides a stack trace for captured exceptions. To provide a stack trace in message events, captured either through `SentrySdk.CaptureMessage` or `Debug.LogError`, you need to set `AttachStacktrace` to `true` in the `Logging` tab in the editor (Tools->Sentry).

## Pages in this section

- [Automatic Error Capture](https://docs.sentry.io/platforms/unity/usage/automatic-error-capture.md)
- [Set the Level](https://docs.sentry.io/platforms/unity/usage/set-level.md)
- [SDK Fingerprinting](https://docs.sentry.io/platforms/unity/usage/sdk-fingerprinting.md)
