File: index.d.ts

package info (click to toggle)
node-plugin-error 1.0.1%2Brepack-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 708 kB
  • sloc: javascript: 5,542; makefile: 2
file content (114 lines) | stat: -rw-r--r-- 2,724 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
declare namespace PluginError {
  interface Constructor {
    /**
     * @param plugin Plugin name
     * @param error Base error
     * @param options Error options
     */
    new <E extends Error>(plugin: string, error: E, options?: Options): PluginError<E>;

    /**
     * @param plugin Plugin name
     * @param error Base error or error message
     * @param options Error options
     */
    new <E extends Error = Error>(plugin: string, error: E | string, options: Options): PluginError<E | {[K in keyof E]: undefined}>;

    /**
     * @param plugin Plugin name
     * @param error Base error, error message, or options with message
     */
    new <E extends Error = Error>(plugin: string, error: E | string | (Options & {message: string})): PluginError<E | {[K in keyof E]: undefined}>;

    /**
     * @param options Options with plugin name and message
     */
    new(options: Options & {plugin: string, message: string}): PluginError;
  }

  interface Options {
    /**
     * Error name
     */
    name?: string;

    /**
     * Error message
     */
    message?: any;

    /**
     * File name where the error occurred
     */
    fileName?: string;


    /**
     * Line number where the error occurred
     */
    lineNumber?: number;

    /**
     * Error properties will be included in err.toString(). Can be omitted by
     * setting this to false.
     *
     * Default: `true`
     */
    showProperties?: boolean;

    /**
     * By default the stack will not be shown. Set this to true if you think the
     * stack is important for your error.
     *
     * Default: `false`
     */
    showStack?: boolean;

    /**
     * Error stack to use for `err.toString()` if `showStack` is `true`.
     * By default it uses the `stack` of the original error if you used one, otherwise it captures a new stack.
     */
    stack?: string;
  }

  /**
   * The `SimplePluginError` interface defines the properties available on all the the instances of `PluginError`.
   *
   * @internal
   */
  interface SimplePluginError extends Error {
    /**
     * Plugin name
     */
    plugin: string;

    /**
     * Boolean controlling if the stack will be shown in `err.toString()`.
     */
    showStack: boolean;

    /**
     * Boolean controlling if properties will be shown in `err.toString()`.
     */
    showProperties: boolean;

    /**
     * File name where the error occurred
     */
    fileName?: string;

    /**
     * Line number where the error occurred
     */
    lineNumber?: number;
  }
}

/**
 * Abstraction for error handling for Vinyl plugins
 */
type PluginError<T = {}> = PluginError.SimplePluginError & T;

declare const PluginError: PluginError.Constructor;

export = PluginError;