@curveball/http-errors
Advanced tools
Comparing version 0.4.0 to 0.4.1
Changelog | ||
========= | ||
0.4.1 (2022-01-15) | ||
------------------ | ||
* `isHttpError` and `isHttpProblem` can now take any (unknown) type as | ||
arguments, making it easier to use these functions without casting. | ||
* `Forbiddden` -> `Forbidden`. | ||
* Update everything to latest curveball defaults. | ||
* Update all dependencies. | ||
0.4.0 (2021-02-18) | ||
@@ -5,0 +14,0 @@ ------------------- |
@@ -10,4 +10,4 @@ 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 function isHttpError(e: unknown): e is HttpError; | ||
export declare function isHttpProblem(e: unknown): e is HttpProblem; | ||
export declare class HttpErrorBase extends Error implements HttpProblem { | ||
@@ -243,3 +243,3 @@ type: string | null; | ||
* Example: | ||
* throw new ServiceUnavailable('We\'re down temporarily', 600) | ||
* throw new TooManyRequests('Try again in 10 minutes', 600) | ||
* | ||
@@ -246,0 +246,0 @@ */ |
@@ -5,2 +5,4 @@ "use strict"; | ||
function isHttpError(e) { | ||
if (!e) | ||
return false; | ||
return Number.isInteger(e.httpStatus); | ||
@@ -10,2 +12,4 @@ } | ||
function isHttpProblem(e) { | ||
if (!e) | ||
return false; | ||
return e.title !== undefined && isHttpError(e); | ||
@@ -80,3 +84,3 @@ } | ||
this.httpStatus = 403; | ||
this.title = 'Forbiddden'; | ||
this.title = 'Forbidden'; | ||
} | ||
@@ -350,3 +354,3 @@ } | ||
* Example: | ||
* throw new ServiceUnavailable('We\'re down temporarily', 600) | ||
* throw new TooManyRequests('Try again in 10 minutes', 600) | ||
* | ||
@@ -353,0 +357,0 @@ */ |
{ | ||
"name": "@curveball/http-errors", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "A standard package for HTTP exceptions", | ||
@@ -36,14 +36,14 @@ "main": "dist/index.js", | ||
"@types/chai": "^4.2.12", | ||
"@types/mocha": "^8.0.3", | ||
"@types/node": "^10.17.35", | ||
"@types/sinon": "^9.0.7", | ||
"@typescript-eslint/eslint-plugin": "^4.3.0", | ||
"@typescript-eslint/parser": "^4.3.0", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^12.20.41", | ||
"@types/sinon": "^10.0.6", | ||
"@typescript-eslint/eslint-plugin": "^5.9.1", | ||
"@typescript-eslint/parser": "^5.9.1", | ||
"chai": "^4.2.0", | ||
"eslint": "^7.10.0", | ||
"mocha": "^8.1.3", | ||
"eslint": "^8.6.0", | ||
"mocha": "^9.1.4", | ||
"nyc": "^15.1.0", | ||
"sinon": "^9.1.0", | ||
"ts-node": "^9.0.0", | ||
"typescript": "^4.0.3" | ||
"sinon": "^12.0.1", | ||
"ts-node": "^10.4.0", | ||
"typescript": "^4.5.4" | ||
}, | ||
@@ -50,0 +50,0 @@ "types": "dist/", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
40823
872