@hapi/boom
Advanced tools
Comparing version 7.4.6 to 7.4.7
@@ -1,79 +0,96 @@ | ||
export interface Payload { | ||
/** | ||
The HTTP status code derived from error.output.statuscode | ||
*/ | ||
statusCode: number | ||
declare namespace boom { | ||
/** | ||
The HTTP status message derived from statusCode | ||
*/ | ||
error: string | ||
interface Payload { | ||
/** | ||
The HTTP status code derived from error.output.statuscode | ||
*/ | ||
statusCode: number | ||
/** | ||
The error message derived from error.message | ||
*/ | ||
message: string | ||
} | ||
/** | ||
The HTTP status message derived from statusCode | ||
*/ | ||
error: string | ||
/** | ||
The error message derived from error.message | ||
*/ | ||
message: string | ||
} | ||
export interface Output { | ||
/** | ||
The HTTP status code | ||
*/ | ||
statusCode: number | ||
interface Output { | ||
/** | ||
The HTTP status code | ||
*/ | ||
statusCode: number | ||
/** | ||
An object containing any HTTP headers where each key is a header name and value is the header content | ||
*/ | ||
headers: object | ||
/** | ||
An object containing any HTTP headers where each key is a header name and value is the header content | ||
*/ | ||
headers: object | ||
/** | ||
The formatted object used as the response payload (stringified) | ||
*/ | ||
payload: Payload | ||
} | ||
/** | ||
The formatted object used as the response payload (stringified) | ||
*/ | ||
payload: Payload | ||
} | ||
interface Options<Data, Decoration> { | ||
/** | ||
The HTTP status code | ||
@default 500 | ||
*/ | ||
statusCode?: number | ||
export interface Options<T> { | ||
/** | ||
The HTTP status code | ||
/** | ||
Additional error information | ||
*/ | ||
data?: Data | ||
@default 500 | ||
*/ | ||
statusCode?: number | ||
/** | ||
An option with extra properties to set on the error object | ||
*/ | ||
decorate?: Decoration | ||
/** | ||
Additional error information | ||
*/ | ||
data?: T | ||
/** | ||
Constructor reference used to crop the exception call stack output | ||
*/ | ||
ctor?: any | ||
/** | ||
An option with extra properties to set on the error object | ||
*/ | ||
decorate?: object | ||
/** | ||
Error message string | ||
@default none | ||
*/ | ||
message?: string | ||
/** | ||
Constructor reference used to crop the exception call stack output | ||
*/ | ||
ctor?: any | ||
/** | ||
If false, the err provided is a Boom object, and a statusCode or message are provided, the values are ignored | ||
@default true | ||
*/ | ||
override?: boolean | ||
} | ||
/** | ||
Error message string | ||
interface MissingAuth { | ||
@default none | ||
*/ | ||
message?: string | ||
/** | ||
Indicate whether the 401 unauthorized error is due to missing credentials (vs. invalid) | ||
*/ | ||
isMissing: boolean | ||
} | ||
} | ||
/** | ||
If false, the err provided is a Boom object, and a statusCode or message are provided, the values are ignored | ||
@default true | ||
*/ | ||
override?: boolean | ||
} | ||
export class Boom<Data = any, Decoration = object> extends Error { | ||
constructor(message?: string | Error, options?: boom.Options<Data, Decoration>) | ||
export class Boom<T = any> extends Error { | ||
/** | ||
Custom error data with additional information specific to the error type | ||
*/ | ||
data: Data | ||
constructor(message?: string | Error, options?: Options<T>) | ||
/** isBoom - if true, indicates this is a Boom object instance. */ | ||
isBoom: boolean; | ||
@@ -83,3 +100,3 @@ /** | ||
*/ | ||
isServer: boolean | ||
isServer: boolean; | ||
@@ -89,13 +106,13 @@ /** | ||
*/ | ||
message: string | ||
message: string; | ||
/** | ||
The constructor used to create the error | ||
The formated response | ||
*/ | ||
typeof: any | ||
output: boom.Output; | ||
/** | ||
The formated response | ||
The constructor used to create the error | ||
*/ | ||
output: Output | ||
typeof: any; | ||
@@ -105,5 +122,5 @@ /** | ||
@param debug - A boolean that, when true, causes Internal Server Error messages to be left in tact | ||
@param debug - A boolean that, when true, does not hide the original 500 error message. Defaults to false. | ||
*/ | ||
reformat(debug: boolean): string | ||
reformat(debug?: boolean): string | ||
@@ -127,3 +144,3 @@ /** | ||
*/ | ||
static boomify<T>(err: Error, options?: Options<T>): Boom<T> | ||
static boomify<Data, Decoration>(err: Error, options?: boom.Options<Data, Decoration>): Boom<Data> & Decoration | ||
@@ -140,3 +157,3 @@ // 4xx Errors | ||
*/ | ||
static badRequest<T>(message?: string, data?: T): Boom<T> | ||
static badRequest<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -152,3 +169,3 @@ /** | ||
*/ | ||
static unauthorized<T>(message?: string | null, scheme?: string, attributes?: object | string): Boom<T> | ||
static unauthorized<Data>(message?: string | null, scheme?: string, attributes?: object | string): Boom<Data> & boom.MissingAuth | ||
@@ -163,3 +180,3 @@ /** | ||
*/ | ||
static unauthorized<T>(message: string | null, wwwAuthenticate: Array<string>): Boom<T> | ||
static unauthorized<Data>(message: string | null, wwwAuthenticate: Array<string>): Boom<Data> | ||
@@ -174,3 +191,3 @@ /** | ||
*/ | ||
static paymentRequired<T>(message?: string, data?: T): Boom<T> | ||
static paymentRequired<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -185,3 +202,3 @@ /** | ||
*/ | ||
static forbidden<T>(message?: string, data?: T): Boom<T> | ||
static forbidden<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -196,3 +213,3 @@ /** | ||
*/ | ||
static notFound<T>(message?: string, data?: T): Boom<T> | ||
static notFound<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -208,3 +225,3 @@ /** | ||
*/ | ||
static methodNotAllowed<T>(message?: string, data?: T, allow?: string | Array<string>): Boom<T> | ||
static methodNotAllowed<Data>(message?: string, data?: Data, allow?: string | Array<string>): Boom<Data> | ||
@@ -219,3 +236,3 @@ /** | ||
*/ | ||
static notAcceptable<T>(message?: string, data?: T): Boom<T> | ||
static notAcceptable<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -230,3 +247,3 @@ /** | ||
*/ | ||
static proxyAuthRequired<T>(message?: string, data?: T): Boom<T> | ||
static proxyAuthRequired<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -241,3 +258,3 @@ /** | ||
*/ | ||
static clientTimeout<T>(message?: string, data?: T): Boom<T> | ||
static clientTimeout<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -252,3 +269,3 @@ /** | ||
*/ | ||
static conflict<T>(message?: string, data?: T): Boom<T> | ||
static conflict<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -263,3 +280,3 @@ /** | ||
*/ | ||
static resourceGone<T>(message?: string, data?: T): Boom<T> | ||
static resourceGone<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -274,3 +291,3 @@ /** | ||
*/ | ||
static lengthRequired<T>(message?: string, data?: T): Boom<T> | ||
static lengthRequired<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -285,3 +302,3 @@ /** | ||
*/ | ||
static preconditionFailed<T>(message?: string, data?: T): Boom<T> | ||
static preconditionFailed<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -296,3 +313,3 @@ /** | ||
*/ | ||
static entityTooLarge<T>(message?: string, data?: T): Boom<T> | ||
static entityTooLarge<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -307,3 +324,3 @@ /** | ||
*/ | ||
static uriTooLong<T>(message?: string, data?: T): Boom<T> | ||
static uriTooLong<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -318,3 +335,3 @@ /** | ||
*/ | ||
static unsupportedMediaType<T>(message?: string, data?: T): Boom<T> | ||
static unsupportedMediaType<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -329,3 +346,3 @@ /** | ||
*/ | ||
static rangeNotSatisfiable<T>(message?: string, data?: T): Boom<T> | ||
static rangeNotSatisfiable<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -340,3 +357,3 @@ /** | ||
*/ | ||
static expectationFailed<T>(message?: string, data?: T): Boom<T> | ||
static expectationFailed<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -351,3 +368,3 @@ /** | ||
*/ | ||
static teapot<T>(message?: string, data?: T): Boom<T> | ||
static teapot<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -362,3 +379,3 @@ /** | ||
*/ | ||
static badData<T>(message?: string, data?: T): Boom<T> | ||
static badData<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -373,3 +390,3 @@ /** | ||
*/ | ||
static locked<T>(message?: string, data?: T): Boom<T> | ||
static locked<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -384,3 +401,3 @@ /** | ||
*/ | ||
static failedDependency<T>(message?: string, data?: T): Boom<T> | ||
static failedDependency<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -395,3 +412,3 @@ /** | ||
*/ | ||
static preconditionRequired<T>(message?: string, data?: T): Boom<T> | ||
static preconditionRequired<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -406,3 +423,3 @@ /** | ||
*/ | ||
static tooManyRequests<T>(message?: string, data?: T): Boom<T> | ||
static tooManyRequests<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -417,3 +434,3 @@ /** | ||
*/ | ||
static illegal<T>(message?: string, data?: T): Boom<T> | ||
static illegal<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -430,3 +447,3 @@ // 5xx Errors | ||
*/ | ||
static badImplementation<T>(message?: string, data?: T): Boom<T> | ||
static badImplementation<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -441,3 +458,3 @@ /** | ||
*/ | ||
static notImplemented<T>(message?: string, data?: T): Boom<T> | ||
static notImplemented<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -452,3 +469,3 @@ /** | ||
*/ | ||
static badGateway<T>(message?: string, data?: T): Boom<T> | ||
static badGateway<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -463,3 +480,3 @@ /** | ||
*/ | ||
static serverUnavailable<T>(message?: string, data?: T): Boom<T> | ||
static serverUnavailable<Data>(message?: string, data?: Data): Boom<Data> | ||
@@ -474,5 +491,5 @@ /** | ||
*/ | ||
static gatewayTimeout<T>(message?: string, data?: T): Boom<T> | ||
static gatewayTimeout<Data>(message?: string, data?: Data): Boom<Data> | ||
} | ||
export default Boom |
@@ -71,7 +71,2 @@ 'use strict'; | ||
static [Symbol.hasInstance](instance) { | ||
return internals.Boom.isBoom(instance); | ||
} | ||
constructor(message, options = {}) { | ||
@@ -98,2 +93,7 @@ | ||
static [Symbol.hasInstance](instance) { | ||
return internals.Boom.isBoom(instance); | ||
} | ||
static isBoom(err) { | ||
@@ -100,0 +100,0 @@ |
{ | ||
"name": "@hapi/boom", | ||
"description": "HTTP-friendly error objects", | ||
"version": "7.4.6", | ||
"version": "7.4.7", | ||
"repository": "git://github.com/hapijs/boom", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27636
638