New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@httpie/http-errors

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@httpie/http-errors

An HTTP error class throwing with proper status codes

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source


HTTP Errors

An HTTP error class throwing with proper status codes


Installation · Usage



Latest Version Monthly downloads

Follow @eldorplus and @httpiejs for updates!

Introduction

The @httpie/http-errors package provides an HTTP error class with useful defaults.

  • provides an HttpError base class with defaults to throw proper HTTP errors
  • the HttpError base class captures stack traces by default
  • create your own HTTP error with custom HTTP status code, title, and error code

Installation

npm i @httpie/http-errors

Quick Usage Overview

Using @httpie/http-errors is pretty straightforward. The package exports the HttpError class that you can use like the native Error class.

const { HttpError } = require('@httpie/http-errors')

// create an HTTP 400 BadRequest error yourself
throw new HttpError('invalid request input data', 400)

// … or throw using shortcut methods
throw HttpError.badRequest('Request validation failed')

// … or use a fluent interface to customize the properties
throw new HttpError('Request validation failed')
  .withStatus(400)
  .withCode('E_YOUR_CUSTOM_ERROR_CODE')

Contributing

Do you miss a function? We very much appreciate your contribution! Please send in a pull request 😊

  • Create a fork
  • Create your feature branch: git checkout -b my-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request 🚀

License

MIT © Supercharge

httpiejs.com  ·  GitHub @httpie  ·  Twitter @httpiejs

Keywords

httpie

FAQs

Package last updated on 24 Sep 2021

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