# @octokit/request-error

> Error class for Octokit request errors

Latest version **7.1.2** (published 2026-08-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @octokit/request-error
pnpm add @octokit/request-error
yarn add @octokit/request-error
bun add @octokit/request-error
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 7.1.2 |
| Published | 2026-08-30 |
| First published | 2019-05-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >= 20 |
| Dependencies | 1 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 19 |
| Author | Gregor Martynus |
| Maintainers | octokitbot, gr2m, wolfy1339 |
| Keywords | octokit, github, api, error |

## Links

- npm: https://www.npmjs.com/package/@octokit/request-error
- Repository: https://github.com/octokit/request-error.js
- Homepage: https://github.com/octokit/request-error.js#readme
- Issues: https://github.com/octokit/request-error.js/issues
- npm.io page: https://npm.io/package/@octokit/request-error

## Dependencies (1)

- [@octokit/types](https://npm.io/package/@octokit/types.md) ^18.0.0

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 7.1.2 (latest) — 2026-08-30
- 5.1.1 (release-5.x) — 2025-02-14
- 6.0.0-beta.5 (beta) — 2024-02-17
- 2.1.0 (next) — 2021-06-11
- 7.1.1 — 2026-08-01
- 7.1.0 — 2025-11-13
- 7.0.2 — 2025-10-30
- 7.0.1 — 2025-09-29
- 7.0.0 — 2025-05-20
- 6.1.8 — 2025-04-10
- 6.1.7 — 2025-02-13
- 6.1.6 — 2024-12-29
- 6.1.5 — 2024-09-24
- 6.1.4 — 2024-07-11
- 6.1.3 — 2024-07-11
- … 36 more at https://npm.io/package/@octokit/request-error/versions

## README

# request-error.js

> Error class for Octokit request errors

[![@latest](https://img.shields.io/npm/v/@octokit/request-error.svg)](https://www.npmjs.com/package/@octokit/request-error)
[![Build Status](https://github.com/octokit/request-error.js/workflows/Test/badge.svg)](https://github.com/octokit/request-error.js/actions?query=workflow%3ATest)

## Usage

<table>
<tbody valign=top align=left>
<tr><th>
Browsers
</th><td width=100%>
Load <code>@octokit/request-error</code> directly from <a href="https://esm.sh">esm.sh</a>

```html
<script type="module">
  import { RequestError } from "https://esm.sh/@octokit/request-error";
</script>
```

</td></tr>
<tr><th>
Node
</th><td>

Install with <code>npm install @octokit/request-error</code>

```js
import { RequestError } from "@octokit/request-error";
```

</td></tr>
</tbody>
</table>

> [!IMPORTANT]
> As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json` by setting `"moduleResolution": "node16", "module": "node16"`.
>
> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).<br>
> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus)

```js
const error = new RequestError("Oops", 500, {
  request: {
    method: "POST",
    url: "https://api.github.com/foo",
    body: {
      bar: "baz",
    },
    headers: {
      authorization: "token secret123",
    },
  },
  response: {
    status: 500,
    url: "https://api.github.com/foo",
    headers: {
      "x-github-request-id": "1:2:3:4",
    },
    data: {
      foo: "bar",
    },
  },
});

error.message; // Oops
error.status; // 500
error.request; // { method, url, headers, body }
error.response; // { url, status, headers, data }
```

### Usage with Octokit

```js
try {
  // your code here that sends at least one Octokit request
  await octokit.request("GET /");
} catch (error) {
  // Octokit errors always have a `error.status` property which is the http response code
  if (error.status) {
    // handle Octokit error
  } else {
    // handle all other errors
    throw error;
  }
}
```

## LICENSE

[MIT](LICENSE)

---
_Source: https://npm.io/package/@octokit/request-error · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
