Comparing version 0.0.17 to 0.0.18
@@ -38,4 +38,2 @@ export = GrpcBoom; | ||
ctor?: (message: string, data: any) => any; | ||
/** an option with extra properties to set on the error object. */ | ||
decorate?: any; | ||
/** message - the error message derived from error.message. */ | ||
@@ -42,0 +40,0 @@ message?: string | Error; |
{ | ||
"name": "grpc-boom", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"description": "A gRPC implementation of the awesome Boom library to help create gRPC-friendly error objects", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -26,3 +26,3 @@ "use strict"; | ||
} | ||
constructor(message, options, errorOnly) { | ||
constructor(message, options) { | ||
super(message); | ||
@@ -37,11 +37,3 @@ const { code, data, ctor } = options ? options : { code: 13, data: null, ctor: GrpcBoom }; | ||
error.serverError = this.serverError; | ||
if (errorOnly) { | ||
return error; | ||
} | ||
Error.captureStackTrace(error, ctor); | ||
error.typeof = ctor; | ||
if (options && options.decorate) { | ||
Object.assign(error, options.decorate); | ||
} | ||
this.initialize(error, code ? code : 13, message); | ||
return error; | ||
@@ -57,9 +49,6 @@ } | ||
options = options || {}; | ||
const grpcBoomInstance = new GrpcBoom('Instance', undefined, true); | ||
const grpcBoomInstance = new GrpcBoom('An internal server error occurred'); | ||
if (options.data !== undefined) { | ||
err.data = options.data; | ||
} | ||
if (options.decorate) { | ||
Object.assign(err, options.decorate); | ||
} | ||
if (!err.isBoom) { | ||
@@ -126,3 +115,7 @@ return grpcBoomInstance.initialize(err, options.code || 13, options.message || err.message || err.output.payload.message); | ||
static create(message, code, data) { | ||
const grpcBoom = new GrpcBoom(message, { code: 16, data, ctor: GrpcBoom.unauthenticated }, false); | ||
const grpcBoom = new GrpcBoom(message, { | ||
code: 16, | ||
data, | ||
ctor: GrpcBoom.unauthenticated | ||
}); | ||
return grpcBoom.initialize(grpcBoom, code, message); | ||
@@ -129,0 +122,0 @@ } |
32954
449