For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inTry it free
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
  • SDKs
    • SDK concepts
    • SDK features
    • Client-side SDKs
    • Server-side SDKs
    • AI SDKs
    • Edge SDKs
    • OpenFeature providers
    • Observability SDKs
      • SDK features
        • Configuration for client-side observability
        • Configuration for server-side observability
        • Configuration for session replay
        • OpenTelemetry in client-side SDKs
        • Recording metrics
        • Recording traces
        • Sending errors
        • Sending logs
        • SDK data handling behavior
        • Self-hosting an OpenTelemetry Collector
        • OpenTelemetry versions and instrumentation support
      • .NET (server-side) SDK observability reference
      • .NET MAUI SDK observability reference
      • Android SDK observability reference
      • iOS SDK observability reference
      • Go SDK observability reference
      • JavaScript SDK observability reference
      • Node.js (server-side) SDK observability reference
      • Python SDK observability reference
      • Ruby SDK observability reference
      • React Native SDK observability reference
      • React Web SDK observability reference
      • Vue SDK observability reference
    • Relay Proxy
Sign inTry it free
LogoLogo
On this page
  • Overview
  • Viewing errors and sourcemaps
  • Client-side SDKs
  • iOS
  • Android
  • JavaScript
  • React Native
  • React Web
  • Vue
  • Server-side SDKs
  • .NET (server-side)
  • Go
  • Node.js (server-side)
  • Python
SDKsObservability SDKsSDK features

Sending errors

Was this page helpful?
Previous

Sending logs

Next
Built with

Overview

The observability plugin automatically sends errors to LaunchDarkly. You can also use recordError to manually send a custom error.

Details about each SDK’s configuration are available in the SDK-specific sections below:

  • Client-side SDKs
  • Server-side SDKs

Viewing errors and sourcemaps

You can view all errors sent to LaunchDarkly under Errors in the LaunchDarkly user interface. To learn more, read Error monitoring.

If you are working with a client-side SDK and using the Errors page in LaunchDarkly to help debug an error, it’s helpful to have a stack trace from the original file in your codebase to help understand what is going wrong. To provide this, LaunchDarkly needs access to the sourcemaps from your codebase. You can send your sourcemaps to LaunchDarkly using the ldcli sourcemaps upload command in the LaunchDarkly CLI. To learn how, read Use ldcli for uploading sourcemaps.

Client-side SDKs

This feature is available in the observability plugin for the following client-side SDKs:

  • iOS
  • Android
  • JavaScript
  • React Native
  • React Web
  • Vue

iOS

Expand iOS code sample

You can use recordError to manually send a custom error:

Record error
1LDObserve.shared.recordLog(message: message, severity: .info, attributes: attributes)

To learn more, read recordError.

Android

Expand Android code sample

You can use recordError to manually send a custom error:

Record error
1LDObserve.recordError(error, attributes)

The attributes argument is optional. To construct it, use Attributes from the @opentelemetry/api.

JavaScript

Expand JavaScript code sample

You can use recordError to manually send a custom error:

Record error
1LDObserve.recordError(error, 'optional message', {
2 component: 'ExampleComponent.tsx',
3});

The message and payload arguments are optional. To learn more, read recordError.

React Native

Expand React Native code sample

You can use recordError to manually send a custom error:

Record error
1LDObserve.recordError(error, attributes, options);

The attributes and options arguments are optional. To construct them, use Attributes and OtelSpan from the @opentelemetry/api. To learn more, read recordError.

React Web

To send a custom error with the React Web SDK, follow the example for JavaScript.

Vue

To send a custom error with the React Web SDK, follow the example for JavaScript.

Server-side SDKs

This feature is available in the observability plugin for the following server-side SDKs:

  • .NET (server-side)
  • Go
  • Node.js (server-side)
  • Python

.NET (server-side)

Expand .NET (server-side) code sample

Use RecordError to manually send a custom error.

Here’s how:

Record error
1Observe.RecordException(exception, metadata)

You can optionally pass an array of attributes, which may include any attributes. We recommend using attributes from the OpenTelemetry specification. To learn more, read RecordLog.

Go

Expand Go code sample

Use RecordError to manually record an error in the current span.

Here’s how:

Record error
1ldobserve.RecordError(ctx, err)

This function takes a Go context.Context and the error. You can optionally pass an array of additional attributes from the OpenTelemetry specification. To learn more, read RecordError.

Node.js (server-side)

Expand Node.js (server-side) code sample

Use recordError to manually send a custom error.

Here’s how:

Record error
1LDObserve.recordError(
2 error,
3 secureSessionId,
4 requestId,
5 metadata,
6 options
7});

The recordError method automatically provides trace context propagation, so you can leave the secureSessionId and requestId undefined. Alternatively, you have the option to set their values, to assist with the context propagation. You can parse values for secureSessionId and requestId from the incoming request using LDObserve.parseHeaders().

The optional metadata can include any attributes from the OpenTelemetry specification. To learn more, read recordError.

Python

Expand Python code sample

Use record_exception to manually send a custom error.

Here’s how:

Record exception
1try:
2 # your application may raise an error
3except Exception as e:
4 observe.record_exception(e)

Passing the Exception records the exception contents and stack trace. You can optionally pass an array of additional Attributes, which may include any attributes from the OpenTelemetry specification. To learn more, read record_exception.