---
title: noticeError
source: https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/noticeerror
---

## Syntax

```js
newrelic.noticeError(error object $error, [object $customAttributes])
```

Identifies a browser error without disrupting your app's operations.

## Requirements

-   Browser Pro or Pro+SPA agent
    -   Custom attributes argument requires agent v1118 or higher
    -   `newrelic.noticeError()` requires agent v499 or higher
    -   `NREUM.noticeError()` requires agent v411 or higher
-   [Enabled browser monitoring](https://docs.newrelic.com/docs/browser/new-relic-browser/getting-started/browser-settings)
-   [Enabled JavaScript monitoring](https://docs.newrelic.com/docs/browser/new-relic-browser/browser-pro-features/javascript-errors-page-detect-analyze-errors)
-   If you're installing the browser agent via npm and building a custom agent with selected features, you must enable the `jserrors` feature when creating the `Agent` instance. In the `features` array, add the following:

    ```js
    import { JSErrors } from '@newrelic/browser-agent/features/jserrors';

    const options = {
      info: { ... },
      loader_config: { ... },
      init: { ... },
      features: [
        JSErrors
      ]
    }
    ```

    For more information, see the [npm browser installation documentation](https://www.npmjs.com/package/@newrelic/browser-agent#new-relic-browser-agent).

## Description

Use this call to notice or log your app's handled or other miscellaneous errors. This is useful when you have caught and handled an error, but you still want to identify it without disrupting your app's operation.

You can also use the API to notice errors that otherwise would be reported without any detail, such as errors that happen during the script initialization or in an inline event handler. The errors will appear in the [**Errors** page](https://docs.newrelic.com/docs/errors-inbox/browser-tab) along with other errors New Relic normally detects. They will also be recorded as a [`JavaScriptError` event](/attribute-dictionary/?event=JavaScriptError). For example:

```js
var err = new Error('Report caught error to New Relic');
newrelic.noticeError(err);
```

Note: If more than 1000 `JavaScriptError` events is sent in a single request, only 1000 separate events is recorded. However, total number of events is preseved internally and accessible by using [`EXTRAPOLATE` query clause](https://docs.newrelic.com/docs/query-your-data/nrql-new-relic-query-language/get-started/nrql-syntax-clauses-functions/#extrapolate).

## Parameters

| Parameter                    | Description                                                                                                                                                                                               |
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `$error` _error object_      | Required. Provide a meaningful error message that you can use when analyzing data on browser's [**Errors** page](https://docs.newrelic.com/docs/errors-inbox/browser-tab).                                |
| `$customAttributes` _object_ | Optional. An object containing name/value pairs representing [custom attributes](https://docs.newrelic.com/docs/data-apis/custom-data/custom-events/report-browser-monitoring-custom-events-attributes/). |

## Examples

### Non-critical errors

This example shows how to use the `newrelic.noticeError` API to report caught errors that you do not want to disrupt your application. This is useful when non-critical errors do not have an impact on the user's experience, but you still want to report them to the developer. The example code safely uses a default `foo` object in case of bad JSON.

```js
var foo;
try {
  foo = JSON.parse('{ "bar"');
} catch (err) {
  // Report caught error to New Relic
  newrelic.noticeError(err);

  foo = { bar: 'default value' };
}
alert(foo.bar);
```

### Callback with optional error [#callback-js]

This example shows how to report an error to New Relic when using the error and response pattern callbacks popularized by Node.js and common in Browserify development. You can replace `alert(body);` with your own relevant message.

```js
var xhr = require('xhr');
xhr('http://localhost:8080', function(err, resp, body) {
  // Report unthrown error to New Relic
  if (err) return newrelic.noticeError(err);
  // Handle successful response
  alert(body);
});
```

### Promise-based API example [#promise-js]

Promises provide a single pattern for handling asynchronous interactions, making it easy to handle asynchronous errors. However, this also makes it easy to ignore errors completely, leaving applications broken in ways that developers cannot see. This example reports those asynchronous errors to New Relic to prevent them from being overlooked.

```js
var rest = require('rest');
rest('/').then(function(res) {
  // Handle successful response
  alert(res.entity);
}, function(err) {
  // Report unthrown error to New Relic
  newrelic.noticeError(err);
});
```

### Capturing custom attributes example [#custom-attributes]

```js
try {
  // code that throws an error
} catch (err) {
  newrelic.noticeError(err, { attribute1: 'value1', attribute2: 2 });
}
```

### Browser limitations (Apple Safari and Microsoft Internet Explorer only) [#browser-limits]

If an error is caught and re-thrown, it will not have a stack trace. For these cases, if you want the `newrelic.noticeError` API to report a stack trace for all browser types, you must pass it to the API in the `catch` statement.

```js
try {
  throw errorObject;
} catch (err) {
  newrelic.noticeError(err);
  throw err; // loses stack trace!
}
```
