---
schema_version: "1"
id: cf684d8e4be8ccf69fd76e3cf1f4400d04e4ce9e4253173cb2df809fcc10a577
title: addErrorHandler()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/aura-platform/guides/aura/container/container-npm-addmessageerrorhandler.md
canonical_url: https://developer.salesforce.com/docs/platform/aura-platform/guide/container-npm-addmessageerrorhandler.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 50d8d722bc5424c2224eeecb8846c1fa0d3058802df7aa19acf3f9000307d42e
products:
  - Lightning Aura Components Developer Guide
  - Platform Developer Content
---

# addErrorHandler()

Mounts an error handling function, to be called when the messaging framework encounters an error.

## Sample

Used within a JavaScript app uploaded as a static resource and referenced by `lightning:container`, this example mounts a message error handling function. In a React app, functions must be mounted to be part of the document-object model and rendered in the output.

```javascript
componentDidMount() {
  LCC.addErrorHandler(this.onMessageError);
}
```

## Arguments

| Name                                   | Type     | Description                                                                      |
| -------------------------------------- | -------- | -------------------------------------------------------------------------------- |
| `handler: (errorMsg: string) => void)` | function | The function that handles error messages encountered in the messaging framework. |

## Response

None.
