Sending errors
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:
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:
JavaScript
Expand JavaScript code sample
You can use recordError
to manually send a custom error:
The message and payload arguments are optional. 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:
Node.js (server-side)
Expand Node.js (server-side) code sample
Use recordError
to manually send a custom error.
Here’s how:
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
.