Add functions for v1.10 (#16281)

- VError.hasCauseWithName
- VError.errorFromList
- VError.errorForEach
This commit is contained in:
hgossler
2017-05-03 11:09:38 -07:00
committed by Mohamed Hegazy
parent 5857473cc7
commit cf786aea6d
2 changed files with 14 additions and 2 deletions
+5 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for verror 1.9
// Type definitions for verror 1.10
// Project: https://github.com/davepacheco/node-verror
// Definitions by: Sven Reglitzki <https://github.com/svi3c/>, Maxime Toumi-M <https://github.com/max4t/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -22,8 +22,11 @@ declare class VError extends Error {
static cause(err: Error): Error | null;
static info(err: Error): VError.Info;
static findCauseByName(err: Error, name: string): Error | null;
static fullStack(err: Error): string;
static findCauseByName(err: Error, name: string): Error | null;
static hasCauseWithName(err: Error, name: string): boolean;
static errorFromList<T extends Error>(errors: T[]): null | T | VError.MultiError;
static errorForEach(err: Error, func: (err: Error) => void): void;
cause(): Error | undefined;
constructor(options: VError.Options | Error, message: string, ...params: any[]);
+9
View File
@@ -25,3 +25,12 @@ const info: { [k: string]: any } = VError.info(verror3);
const namedCause: Error | null = VError.findCauseByName(verror3, "fooError");
const stack: string = VError.fullStack(verror3);
const cause3: Error | null = VError.cause(verror3);
// Added in v1.9
const hasCause: boolean = VError.hasCauseWithName(error, "name");
// Added in v1.10
const toList1: null|VError|MultiError = VError.errorFromList([verror1]);
const toList2: null|Error|MultiError = VError.errorFromList([error, verror1]);
VError.errorForEach(multiError, (error: Error) => {});