@golemio/errors
Advanced tools
Comparing version 2.0.0-dev.877231197 to 2.0.0-dev.878768479
@@ -10,3 +10,3 @@ import { IGolemioErrorInfoType } from "./interfaces/GolemioErrorInterface"; | ||
toObject: () => IGolemioError; | ||
private causeToString; | ||
private infoToString; | ||
} |
@@ -11,6 +11,6 @@ "use strict"; | ||
+ this.message | ||
+ `${this.info ? ` (${this.causeToString(this.info)})` : ``}` | ||
+ `${this.info ? ` (${this.infoToString(this.info)})` : ``}` | ||
+ `${process.env.NODE_ENV === "development" ? `\n ${this.stack}` : ``}`; | ||
}; | ||
this.toObject = () => (Object.assign(Object.assign(Object.assign(Object.assign({ error_message: this.message }, (this.className && { error_class_name: this.className })), (this.status && { error_status: this.status })), this.info && { error_info: this.causeToString(this.info) }), (process.env.NODE_ENV === "development") && { error_stack: this.stack })); | ||
this.toObject = () => (Object.assign(Object.assign(Object.assign(Object.assign({ error_message: this.message }, (this.className && { error_class_name: this.className })), (this.status && { error_status: this.status })), this.info && { error_info: this.infoToString(this.info) }), (process.env.NODE_ENV === "development") && { error_stack: this.stack })); | ||
this.name = this.constructor.name; | ||
@@ -23,11 +23,11 @@ this.message = message; | ||
} | ||
causeToString(cause) { | ||
if (cause instanceof AbstractGolemioError) { | ||
return cause.toString(); | ||
infoToString(info) { | ||
if (info instanceof AbstractGolemioError) { | ||
return info.toString(); | ||
} | ||
else if (cause instanceof Error) { | ||
return cause.message; | ||
else if (info instanceof Error) { | ||
return info.message; | ||
} | ||
else { | ||
return typeof cause === "string" ? cause : JSON.stringify(cause); | ||
return typeof info === "string" ? info : JSON.stringify(info); | ||
} | ||
@@ -34,0 +34,0 @@ } |
@@ -8,3 +8,3 @@ export interface IGolemioError { | ||
} | ||
export interface ICustomError extends IGolemioError { | ||
export interface ICustomErrorObject extends IGolemioError { | ||
} | ||
@@ -11,0 +11,0 @@ export declare type IGolemioErrorInfoType = Error | IGolemioErrorInfoObject | IGolemioErrorInfoObject[] | string; |
{ | ||
"name": "@golemio/errors", | ||
"version": "2.0.0-dev.877231197", | ||
"version": "2.0.0-dev.878768479", | ||
"description": "Library of Error classes of the Golemio Data Platform System", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
36289