From cf786aea6d593d79d6a0e6967c52872ec1011edb Mon Sep 17 00:00:00 2001 From: hgossler Date: Wed, 3 May 2017 12:09:38 -0600 Subject: [PATCH] Add functions for v1.10 (#16281) - VError.hasCauseWithName - VError.errorFromList - VError.errorForEach --- types/verror/index.d.ts | 7 +++++-- types/verror/verror-tests.ts | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/types/verror/index.d.ts b/types/verror/index.d.ts index b8a14ae425..a77a81f349 100644 --- a/types/verror/index.d.ts +++ b/types/verror/index.d.ts @@ -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 , Maxime Toumi-M // 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(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[]); diff --git a/types/verror/verror-tests.ts b/types/verror/verror-tests.ts index efb52c9178..c3b560bfb2 100644 --- a/types/verror/verror-tests.ts +++ b/types/verror/verror-tests.ts @@ -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) => {});