Report Custom Errors¶
The Browser RUM SDK automatically collects unhandled frontend exceptions. For exceptions that have already been caught by business code but still require monitoring, use addError(error, context?) to report them proactively.
Parameters¶
| Parameter | Type | Required | Description |
|---|---|---|---|
error |
Unknown | Yes | It is recommended to pass the original Error object to preserve the message and stack. |
context |
Object | No | Business fields when the error occurs, such as page state, API name, or retry count. |
NPM Example¶
import { datafluxRum } from "@cloudcare/browser-rum"
async function submit() {
try {
await submitOrder()
} catch (error) {
datafluxRum.addError(error, {
operation: "submit_order",
retry_count: 1
})
}
}
CDN Example¶
Notes¶
- Pass the original
Errorobject whenever possible; do not pass onlyerror.message. - Do not include sensitive data such as passwords, tokens, or full request bodies in the Context.
- If the same exception is both automatically collected by the SDK and reported via
addError(), two Error data entries will be created. Only call this API for exceptions that have been handled or proactively identified by the business logic.
Validation¶
After triggering the exception, go to the Error Explorer of the corresponding web application, filter by the operation field with the value submit_order, and check the error message, stack, and custom Context.