mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-06 13:11:46 +00:00
verror: Put other exports into a namespace merged with class VError (#13612)
This commit is contained in:
Vendored
+38
-43
@@ -3,20 +3,6 @@
|
||||
// Definitions by: Sven Reglitzki <https://github.com/svi3c/>, Maxime Toumi-M <https://github.com/max4t/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
// tslint:disable-next-line:functional-interfaces
|
||||
interface VErrorInfo {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
declare interface VErrorOptions {
|
||||
cause?: Error | null | undefined;
|
||||
name?: string;
|
||||
strict?: boolean;
|
||||
constructorOpt?: (...args: any[]) => void;
|
||||
info?: VErrorInfo;
|
||||
}
|
||||
|
||||
/*
|
||||
* VError([cause], fmt[, arg...]): Like JavaScript's built-in Error class, but
|
||||
* supports a "cause" argument (another error) and a printf-style message. The
|
||||
@@ -33,47 +19,56 @@ declare interface VErrorOptions {
|
||||
*/
|
||||
declare class VError extends Error {
|
||||
static VError: typeof VError;
|
||||
static SError: typeof SError;
|
||||
static MultiError: typeof MultiError;
|
||||
static WError: typeof WError;
|
||||
|
||||
static cause(err: Error): Error | null;
|
||||
static info(err: Error): VErrorInfo;
|
||||
static info(err: Error): VError.Info;
|
||||
static findCauseByName(err: Error, name: string): Error | null;
|
||||
static fullStack(err: Error): string;
|
||||
|
||||
cause(): Error | undefined;
|
||||
constructor(options: VErrorOptions, message: string, ...params: any[]);
|
||||
constructor(options: VError.Options, message: string, ...params: any[]);
|
||||
constructor(cause: Error, message: string, ...params: any[]);
|
||||
constructor(message: string, ...params: any[]);
|
||||
}
|
||||
|
||||
/*
|
||||
* SError is like VError, but stricter about types. You cannot pass "null" or
|
||||
* "undefined" as string arguments to the formatter. Since SError is only a
|
||||
* different function, not really a different class, we don't set
|
||||
* SError.prototype.name.
|
||||
*/
|
||||
declare class SError extends VError {
|
||||
}
|
||||
declare namespace VError {
|
||||
interface Info {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/*
|
||||
* Represents a collection of errors for the purpose of consumers that generally
|
||||
* only deal with one error. Callers can extract the individual errors
|
||||
* contained in this object, but may also just treat it as a normal single
|
||||
* error, in which case a summary message will be printed.
|
||||
*/
|
||||
declare class MultiError extends VError {
|
||||
constructor(errors: Error[]);
|
||||
errors(): Error[];
|
||||
}
|
||||
interface Options {
|
||||
cause?: Error | null | undefined;
|
||||
name?: string;
|
||||
strict?: boolean;
|
||||
constructorOpt?: (...args: any[]) => void;
|
||||
info?: Info;
|
||||
}
|
||||
|
||||
/*
|
||||
* Like JavaScript's built-in Error class, but supports a "cause" argument which
|
||||
* is wrapped, not "folded in" as with VError. Accepts a printf-style message.
|
||||
* The cause argument can be null.
|
||||
*/
|
||||
declare class WError extends VError {
|
||||
/*
|
||||
* SError is like VError, but stricter about types. You cannot pass "null" or
|
||||
* "undefined" as string arguments to the formatter. Since SError is only a
|
||||
* different function, not really a different class, we don't set
|
||||
* SError.prototype.name.
|
||||
*/
|
||||
class SError extends VError {}
|
||||
|
||||
/*
|
||||
* Represents a collection of errors for the purpose of consumers that generally
|
||||
* only deal with one error. Callers can extract the individual errors
|
||||
* contained in this object, but may also just treat it as a normal single
|
||||
* error, in which case a summary message will be printed.
|
||||
*/
|
||||
class MultiError extends VError {
|
||||
constructor(errors: Error[]);
|
||||
errors(): Error[];
|
||||
}
|
||||
|
||||
/*
|
||||
* Like JavaScript's built-in Error class, but supports a "cause" argument which
|
||||
* is wrapped, not "folded in" as with VError. Accepts a printf-style message.
|
||||
* The cause argument can be null.
|
||||
*/
|
||||
class WError extends VError {}
|
||||
}
|
||||
|
||||
export = VError;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
+5
-10
@@ -1,17 +1,12 @@
|
||||
// Type definitions for verror v1.6.0
|
||||
// Project: https://github.com/davepacheco/node-verror
|
||||
// Definitions by: Sven Reglitzki <https://github.com/svi3c/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
import VError = require("verror");
|
||||
import { VError as VError2, MultiError, SError, WError } from "verror";
|
||||
|
||||
var error = new Error("foo");
|
||||
var verror1 = new VError(error, "bar");
|
||||
var verror2 = new VError.VError(error, "bar");
|
||||
var serror = new VError.SError(error, "bar");
|
||||
var multiError = new VError.MultiError([verror1, verror2]);
|
||||
var werror = new VError.WError(verror1, "foobar");
|
||||
var verror2 = new VError2(error, "bar");
|
||||
var serror = new SError(error, "bar");
|
||||
var multiError = new MultiError([verror1, verror2]);
|
||||
var werror = new WError(verror1, "foobar");
|
||||
|
||||
var verror3 = new VError({
|
||||
name: "fooError",
|
||||
|
||||
Reference in New Issue
Block a user