---
title: Reporting errors
description: Report errors from JavaScript applications to Honeybadger with automatic notifications and custom error handling.
url: https://docs.honeybadger.io/lib/javascript/errors/reporting-errors/
---

Honeybadger reports uncaught exceptions automatically. In all other cases, use `Honeybadger.notify(error)` to send any error to Honeybadger.

To catch an exception and notify Honeybadger without re-throwing:

```javascript
try {
  throw "oops";
} catch (error) {
  Honeybadger.notify(error);
}
```

## Customizing the error name

JavaScript often uses generic class names — such as `Error` — which are uninformative and also cause unrelated errors to be grouped together. To get around this issue it’s a good practice to send a custom error class when notifying Honeybadger:

```javascript
Honeybadger.notify(error, "DescriptiveClass");
```

## Additional options

You can also set or override other optional data which is reported with the error:

```javascript
Honeybadger.notify(error, {
  message: "My custom message",
  name: "DescriptiveClass",
  component: "badgers",
  action: "show",
  context: { badgerId: 1 },
  fingerprint: "This unique string will group similar errors together",
  environment: "production",
  projectRoot: "https://www.example.com/",
  params: { key: "value" },
  cookies: { key: "value" }, // May also be sent as a string in the document.cookie "foo=bar;bar=baz" format.
  tags: ["tag-1", "tag-2"],
});
```

## Other ways to notify

You can notify Honeybadger of anything, even if you don’t have an error object:

```javascript
Honeybadger.notify('Badgers!');
Honeybadger.notify('Badgers!', { ... });
Honeybadger.notify('Badgers!', 'CustomClass');
Honeybadger.notify('Badgers!', 'CustomClass', { ... });
Honeybadger.notify({
  message: 'Badgers!',
  name: 'CustomClass',
  ...
});
```

A stacktrace will be generated for you (when possible) if you do not provide an error object.

## `Honeybadger.notify()` return value

`Honeybadger.notify()` returns a boolean indicating whether the error will be reported to Honeybadger. When calling this method, some precondition checks are performed, such as checking if the client is configured or if the error is ignored based on the environment. Additionally, the [`beforeNotify`](https://docs.honeybadger.io/lib/javascript/errors/customizing-error-reports/#adding-context) handlers are called. If any of these checks return `false`, the error will not be reported and `notify()` will return `false`.

Note

If there are any `async beforeNotify` handlers defined, `notify()` will return `true` by default since the result is synchronous.

---

## Try Honeybadger for FREE

Intelligent logging, error tracking, and Just Enough APM™ in one dev-friendly platform. Find and fix problems before users notice.

[Start free trial](https://app.honeybadger.io/users/sign_up)

[See plans and pricing](https://www.honeybadger.io/plans/)
