Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@octokit/request-error

Package Overview
Dependencies
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/request-error

Error class for Octokit request errors

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.3M
decreased by-15.92%
Maintainers
3
Weekly downloads
 
Created

What is @octokit/request-error?

The @octokit/request-error npm package is designed to handle errors that occur during requests made using the Octokit library, which is a GitHub API client. It provides a structured way to catch and process errors, making it easier to debug and handle exceptions in applications that interact with GitHub's API.

What are @octokit/request-error's main functionalities?

Creating a RequestError instance

This feature allows developers to create an instance of RequestError, providing a message, status code, and request details. This can be useful for simulating errors in tests or handling errors in a structured way.

const { RequestError } = require('@octokit/request-error');

const error = new RequestError('Message describing the error', 404, {
  request: {
    method: 'GET',
    url: 'https://api.github.com/repos/octocat/Hello-World',
    headers: {
      authorization: 'token secret123'
    }
  }
});

Accessing error details

Once a RequestError instance is created, developers can access various details about the error, such as the HTTP status code, error message, and the request that caused the error. This is particularly useful for logging and debugging purposes.

const error = new RequestError('Not Found', 404, {
  request: {
    method: 'GET',
    url: 'https://api.github.com/repos/octocat/Hello-World',
    headers: {
      authorization: 'token secret123'
    }
  }
});

console.log(error.status); // 404
console.log(error.message); // Not Found
console.log(error.request.method); // GET

Other packages similar to @octokit/request-error

Keywords

FAQs

Package last updated on 04 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc