Nostradamus Prophecy Machine

    @octokit/request-error
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.0 • Public • Published

    http-error.js

    Error class for Octokit request errors

    @latest Build Status

    Usage

    Browsers Load @octokit/request-error directly from cdn.skypack.dev
    <script type="module">
    import { RequestError } from "https://cdn.skypack.dev/@octokit/request-error";
    </script>
    Node

    Install with npm install @octokit/request-error

    const { RequestError } = require("@octokit/request-error");
    // or: import { RequestError } from "@octokit/request-error";
    const error = new RequestError("Oops", 500, {
      headers: {
        "x-github-request-id": "1:2:3:4",
      }, // response headers
      request: {
        method: "POST",
        url: "https://api.github.com/foo",
        body: {
          bar: "baz",
        },
        headers: {
          authorization: "token secret123",
        },
      },
    });
    
    error.message; // Oops
    error.status; // 500
    error.request.method; // POST
    error.request.url; // https://api.github.com/foo
    error.request.body; // { bar: 'baz' }
    error.request.headers; // { authorization: 'token [REDACTED]' }
    error.response; // { url, status, headers, data }

    LICENSE

    MIT

    Install

    npm i @octokit/request-error

    DownloadsWeekly Downloads

    6,425,495

    Version

    2.1.0

    License

    MIT

    Unpacked Size

    21.9 kB

    Total Files

    11

    Last publish

    Collaborators

    • gr2m
    • octokitbot