Error interceptor
Error interceptor can obscure sensitive data from any recorded errors.
Error events can be completely omitted by returning false
from the interceptor.
Example error interceptor
{
interceptors: {
error: (data, context) => {
if (context.pageUrl.includes('/profile')) {
// do not record any errors from `/profile` page
return false;
}
if (data.message?.startsWith('Failed to load')) {
// Do not record resource failed to load error,
// i.e. for example when img fails to load due to some network error
// See more at:
// https://developer.mozilla.org/en-US/docs/Web/API/Element/error_event
return false;
}
}
}
Parameters
Parameter | Type | Description |
---|---|---|
data | object | |
data.message | string | Human-readable description of the error |
data.filename | string | undefined | Path to the file that raised the error |
data.colno | number | undefined | Column number in the line of the file that raised the error |
data.lineno | number | undefined | Line number in the file that raised the error |
data.stack | string | undefined | Trace of which functions were called, in what order, from which line and file, and with what arguments |
data.url | string | URL of the page where the error happened |
context | ErrorEvent | PromiseRejectionEvent | Error | string | Type can be one of ErrorEvent, PromiseRejectionEvent, Error, or string if using Error API |
Updated over 1 year ago