Skip to main content
Error monitoring is the core functionality of Sentry. The SDK automatically captures unhandled errors and allows you to manually capture exceptions with rich context.

Capturing Exceptions

Use captureException() to manually send exceptions to Sentry:

With Additional Context

Add extra context when capturing exceptions:
The captureException method returns an event ID that you can use to reference the error later.

Capturing Messages

For non-error events, use captureMessage() to send messages to Sentry:

Severity Levels

Messages support different severity levels:

Capturing Custom Events

For full control, capture custom events with captureEvent():

Event IDs

All capture methods return an event ID:
The lastEventId() function returns the last recorded error on the current isolation scope. If another error is captured in between, it will return that one instead.

Checking SDK Status

Verify that Sentry is properly initialized:

Flushing Events

Manually flush pending events:
Use flush() before your application exits to ensure all events are sent to Sentry.

Error Filtering

Filter errors before they’re sent using the beforeSend callback:

Next Steps

Scopes

Learn how to use scopes to add context to events

Context

Add rich contextual data to your error reports

Breadcrumbs

Track user actions leading up to errors

Event Processors

Process and modify events before they’re sent