Usage

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.

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.

Capturing Errors

In C# you can capture any exception object that you caught:

Copied
using Sentry;

try
{
    AFunctionThatMightFail();
}
catch (Exception err)
{
    SentrySdk.CaptureException(err);
}

Ignoring Errors

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

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

This modifies the behavior of the entire inheritance chain. As a result, the example code will also filter out TaskCanceledException since it derives from OperationCanceledException.

Capturing Messages

Another common operation is to capture a bare message. A message is textual information that should be sent to Sentry. Typically messages are not emitted, but they can be useful for some teams.

Copied
using Sentry;

SentrySdk.CaptureMessage("Something went wrong");