@jamashita/anden-error
Advanced tools
Comparing version 2.12.0 to 2.13.0
@@ -7,2 +7,3 @@ "use strict"; | ||
class Errors extends RuntimeError_1.RuntimeError { | ||
errors; | ||
constructor(...errors) { | ||
@@ -9,0 +10,0 @@ const message = errors.map((error) => { |
export declare abstract class RuntimeError extends Error { | ||
private readonly cause; | ||
protected constructor(message: string, cause?: Error); | ||
@@ -4,0 +3,0 @@ private stackErrors; |
@@ -5,7 +5,10 @@ "use strict"; | ||
const anden_type_1 = require("@jamashita/anden-type"); | ||
const SEPARATOR_TEXT = '\n\nThe following exception was the direct cause of the above exception:\n\n'; | ||
const SEPARATOR_TEXT = '\nCaused by'; | ||
class RuntimeError extends Error { | ||
constructor(message, cause) { | ||
super(message); | ||
this.cause = cause; | ||
if (anden_type_1.Kind.isUndefined(cause)) { | ||
super(message); | ||
return; | ||
} | ||
super(message, { cause }); | ||
} | ||
@@ -30,3 +33,5 @@ stackErrors(error, chain) { | ||
return chain.map((err) => { | ||
return err.message; | ||
return err.stack; | ||
}).filter((stack) => { | ||
return !anden_type_1.Kind.isUndefined(stack); | ||
}).join(SEPARATOR_TEXT); | ||
@@ -33,0 +38,0 @@ } |
import { Kind } from '@jamashita/anden-type'; | ||
import { RuntimeError } from './RuntimeError'; | ||
export class Errors extends RuntimeError { | ||
errors; | ||
constructor(...errors) { | ||
@@ -5,0 +6,0 @@ const message = errors.map((error) => { |
export declare abstract class RuntimeError extends Error { | ||
private readonly cause; | ||
protected constructor(message: string, cause?: Error); | ||
@@ -4,0 +3,0 @@ private stackErrors; |
import { Kind } from '@jamashita/anden-type'; | ||
const SEPARATOR_TEXT = '\n\nThe following exception was the direct cause of the above exception:\n\n'; | ||
const SEPARATOR_TEXT = '\nCaused by'; | ||
export class RuntimeError extends Error { | ||
constructor(message, cause) { | ||
super(message); | ||
this.cause = cause; | ||
if (Kind.isUndefined(cause)) { | ||
super(message); | ||
return; | ||
} | ||
super(message, { cause }); | ||
} | ||
@@ -26,3 +29,5 @@ stackErrors(error, chain) { | ||
return chain.map((err) => { | ||
return err.message; | ||
return err.stack; | ||
}).filter((stack) => { | ||
return !Kind.isUndefined(stack); | ||
}).join(SEPARATOR_TEXT); | ||
@@ -29,0 +34,0 @@ } |
{ | ||
"name": "@jamashita/anden-error", | ||
"version": "2.12.0", | ||
"version": "2.13.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "repository": { |
import { Ambiguous, Kind } from '@jamashita/anden-type'; | ||
const SEPARATOR_TEXT: string = '\n\nThe following exception was the direct cause of the above exception:\n\n'; | ||
const SEPARATOR_TEXT: string = '\nCaused by'; | ||
export abstract class RuntimeError extends Error { | ||
private readonly cause: Ambiguous<Error>; | ||
protected constructor(message: string, cause?: Error) { | ||
if (Kind.isUndefined(cause)) { | ||
super(message); | ||
return; | ||
} | ||
protected constructor(message: string, cause?: Error) { | ||
super(message); | ||
this.cause = cause; | ||
super(message, { cause }); | ||
} | ||
@@ -36,6 +38,8 @@ | ||
return chain.map((err: Error): string => { | ||
return err.message; | ||
return chain.map((err: Error): Ambiguous<string> => { | ||
return err.stack; | ||
}).filter((stack: Ambiguous<string>): stack is string => { | ||
return !Kind.isUndefined(stack); | ||
}).join(SEPARATOR_TEXT); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
71640
332