4.0.1 • Published 8 years ago

web-error v4.0.1

Weekly downloads
214
License
MIT
Repository
github
Last release
8 years ago

Web Error

Custom error object with code of http error

Example

import WebError from 'web-error';

// CommonJS
var WebError = require('web-error').default;

const error = new WebError(404, 'My message');

error.status.should.equal(400);
(error instanceof Error).should.equal(true);
(error instanceof WebError).should.equal(true);

BadRequest

import { BadRequest } from 'web-error';

// CommonJS
var WebError = require('web-error').default;

const error = new BadRequest('My message');

error.status.should.equal(400);
(error instanceof Error).should.equal(true);
(error instanceof WebError).should.equal(true);
(error instanceof BadRequest).should.equal(true);

Unauthorized

import { Unauthorized } from 'web-error';

// CommonJS
var WebError = require('web-error').default;

const error = new BadRequest('My message');

error.status.should.equal(401);
(error instanceof Error).should.equal(true);
(error instanceof WebError).should.equal(true);
(error instanceof Unauthorized).should.equal(true);

List of all classes

Status CodeConstructor Name
400BadRequest
401Unauthorized
402PaymentRequired
403Forbidden
404NotFound
405MethodNotAllowed
406NotAcceptable
407ProxyAuthenticationRequired
408RequestTimeout
409Conflict
410Gone
411LengthRequired
412PreconditionFailed
413PayloadTooLarge
414URITooLong
415UnsupportedMediaType
416RangeNotSatisfiable
417ExpectationFailed
418ImATeapot
421MisdirectedRequest
422UnprocessableEntity
423Locked
424FailedDependency
425UnorderedCollection
426UpgradeRequired
428PreconditionRequired
429TooManyRequests
431RequestHeaderFieldsTooLarge
451UnavailableForLegalReasons
500InternalServerError
501NotImplemented
502BadGateway
503ServiceUnavailable
504GatewayTimeout
505HTTPVersionNotSupported
506VariantAlsoNegotiates
507InsufficientStorage
508LoopDetected
509BandwidthLimitExceeded
510NotExtended
511NetworkAuthenticationRequired
4.0.1

8 years ago

3.1.2

9 years ago

3.1.1

9 years ago

3.1.0

9 years ago

3.0.2

9 years ago

3.0.1

9 years ago

3.0.0

9 years ago

2.0.0

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago