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

@curveball/http-errors

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@curveball/http-errors - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

8

changelog.md

@@ -0,1 +1,8 @@

0.2.2 (2018-09-14)
==================
* Added `isHttpProblem()` helper function.
* Added 408, 409, 410, 411, 412, 413.
0.2.1 (2018-09-14)

@@ -7,2 +14,3 @@ ==================

0.2.0 (2018-09-12)

@@ -9,0 +17,0 @@ ==================

@@ -9,2 +9,3 @@ export interface HttpError extends Error {

export declare function isHttpError(e: Error): e is HttpError;
export declare function isHttpProblem(e: Error): e is HttpProblem;
export declare class HttpErrorBase extends Error implements HttpProblem {

@@ -101,2 +102,54 @@ httpCode: number;

/**
* Emits 408 Request Timeout
*/
export declare class RequestTimeout extends HttpErrorBase {
httpCode: number;
title: string;
}
/**
* Emits 409 Conflict
*/
export declare class Conflict extends HttpErrorBase {
httpCode: number;
title: string;
}
/**
* Emits 410 Gone
*/
export declare class Gone extends HttpErrorBase {
httpCode: number;
title: string;
}
/**
* Emits 411 Length Required
*/
export declare class LengthRequired extends HttpErrorBase {
httpCode: number;
title: string;
}
/**
* Emits 412 Precondition Failed
*/
export declare class PreconditionFailed extends HttpErrorBase {
httpCode: number;
title: string;
}
/**
* Emits 413 Payload Too Large.
*
* If the status is temporary, it's possible for a server to send a
* Retry-After header to try again. This value may be embeded in this
* exception.
*
* Example:
*
* throw new PayloadTooLarge('Send the large file again in 10 minutes', 600);
*/
export declare class PayloadTooLarge extends HttpErrorBase {
httpCode: number;
title: string;
retryAfter: number | null;
constructor(detail?: string | null, retryAfter?: number | null);
}
/**
* Emits 422 Unprocessable Entity

@@ -103,0 +156,0 @@ */

@@ -7,2 +7,6 @@ "use strict";

exports.isHttpError = isHttpError;
function isHttpProblem(e) {
return e.title !== undefined && isHttpError(e);
}
exports.isHttpProblem = isHttpProblem;
class HttpErrorBase extends Error {

@@ -140,2 +144,77 @@ constructor(detail = null) {

/**
* Emits 408 Request Timeout
*/
class RequestTimeout extends HttpErrorBase {
constructor() {
super(...arguments);
this.httpCode = 408;
this.title = 'Request Timeout';
}
}
exports.RequestTimeout = RequestTimeout;
/**
* Emits 409 Conflict
*/
class Conflict extends HttpErrorBase {
constructor() {
super(...arguments);
this.httpCode = 409;
this.title = 'Conflict';
}
}
exports.Conflict = Conflict;
/**
* Emits 410 Gone
*/
class Gone extends HttpErrorBase {
constructor() {
super(...arguments);
this.httpCode = 410;
this.title = 'Gone';
}
}
exports.Gone = Gone;
/**
* Emits 411 Length Required
*/
class LengthRequired extends HttpErrorBase {
constructor() {
super(...arguments);
this.httpCode = 411;
this.title = 'LengthRequired';
}
}
exports.LengthRequired = LengthRequired;
/**
* Emits 412 Precondition Failed
*/
class PreconditionFailed extends HttpErrorBase {
constructor() {
super(...arguments);
this.httpCode = 412;
this.title = 'PreconditionFailed';
}
}
exports.PreconditionFailed = PreconditionFailed;
/**
* Emits 413 Payload Too Large.
*
* If the status is temporary, it's possible for a server to send a
* Retry-After header to try again. This value may be embeded in this
* exception.
*
* Example:
*
* throw new PayloadTooLarge('Send the large file again in 10 minutes', 600);
*/
class PayloadTooLarge extends HttpErrorBase {
constructor(detail = null, retryAfter = null) {
super(detail);
this.httpCode = 413;
this.title = 'Payload Too Large';
this.retryAfter = retryAfter;
}
}
exports.PayloadTooLarge = PayloadTooLarge;
/**
* Emits 422 Unprocessable Entity

@@ -142,0 +221,0 @@ */

2

package.json
{
"name": "@curveball/http-errors",
"version": "0.2.1",
"version": "0.2.2",
"description": "A standard package for HTTP exceptions",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

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