2.0.0 • Published 5 years ago

easy-http-errors v2.0.0

Weekly downloads
575
License
MIT
Repository
github
Last release
5 years ago

Easy Http Errors

npm node Build Status Coverage Status

A preset of HTTP errors that can be easily used to throw errors in your applications.

Installation

NPM

npm i easy-http-errors --save

Yarn

yarn add easy-http-errors

Usage

// ES6 import.
import { BadRequestError } from 'easy-http-errors';

// Throw the default bad request.
throw new BadRequestError();

// Throw a bad request with a custom message and properties.
throw new BadRequestError('Ups, this is a bad request', { foo: 'bar' });

List of errors

Status CodeName
400BadRequestError
401UnauthorizedError
402PaymentRequiredError
403ForbiddenError
404NotFoundError
405MethodNotAllowedError
406NotAcceptableError
407ProxyAuthenticationRequiredError
408RequestTimeoutError
409ConflictError
410GoneError
411LengthRequiredError
412PreconditionFailedError
413PayloadTooLargeError
414URITooLongError
415UnsupportedMediaTypeError
416RangeNotSatisfiableError
417ExpectationFailedError
418ImATeapotError
421MisdirectedRequestError
422UnprocessableEntityError
423LockedError
424FailedDependencyError
425UnorderedCollectionError
426UpgradeRequiredError
428PreconditionRequiredError
429TooManyRequestsError
431RequestHeaderFieldsTooLargeError
451UnavailableForLegalReasonsError
500InternalServerError
501NotImplementedError
502BadGatewayError
503ServiceUnavailableError
504GatewayTimeoutError
505HTTPVersionNotSupportedError
506VariantAlsoNegotiatesError
507InsufficientStorageError
508LoopDetectedError
509BandwidthLimitExceededError
510NotExtendedError
511NetworkAuthenticationRequiredError

Tests

Run the tests from the root directory:

npm test

Contributing & Development

Contributing

Found a bug or want to suggest something? Take a look first on the current and closed issues. If it is something new, please submit an issue.

Develop

It will be awesome if you can help us evolve easy-http-errors. Want to help?

  1. Fork it.
  2. npm install.
  3. Hack away.
  4. Run the tests: npm test.
  5. Create a Pull Request.