setErrorHandler

newrelic.setErrorHandler(error object $error, function $callback)
Allows selective ignoring of known errors that the Browser agent captures.

Requirements

Agent version nr-974 or higher.

Description

The newrelic.setErrorHandler() API call allows you to selectively ignore known errors that the Browser agent captures. It takes a single error handler function, which will be called for each error that the Browser agent captures. If the handler returns true, New Relic does not record the error. Otherwise the error will be processed normally.

Parameters

Parameter Description

error

error object

Required. This will usually be an error object, but it can be other data types.

You can include the error object inside of the callback function.

callback

function

Required. The callback will be called with each error, so it is not specific to one error.

Example(s)

Use a single error handler function

Include the error object inside of the callback function to ignore specific errors that the Browser agent captures.

newrelic.setErrorHandler(function (err) {
   if (shouldIgnoreError(err)) {
     return true
   } else {
     return false
   }
})

For more help

Recommendations for learning more: