summaryrefslogtreecommitdiffstats
path: root/node_modules/npm-run-all/lib/npm-run-all-error.js
blob: af08b094d91748911ae94071fe4cd70a51413e6c (plain) (blame)
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
/**
 * @module npm-run-all-error
 * @author Toru Nagashima
 * @copyright 2016 Toru Nagashima. All rights reserved.
 * See LICENSE file in root directory for full license.
 */
"use strict"

//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------

/**
 * Error object with some additional info.
 */
module.exports = class NpmRunAllError extends Error {
    /**
     * Constructor.
     *
     * @param {{name: string, code: number}} causeResult -
     *      The result item of the npm-script which causes an error.
     * @param {Array.<{name: string, code: (number|undefined)}>} allResults -
     *      All result items of npm-scripts.
     */
    constructor(causeResult, allResults) {
        super(`"${causeResult.task}" exited with ${causeResult.code}.`)

        /**
         * The name of a npm-script which exited with a non-zero code.
         * @type {string}
         */
        this.name = causeResult.name

        /**
         * The code of a npm-script which exited with a non-zero code.
         * This can be `undefined`.
         * @type {number}
         */
        this.code = causeResult.code

        /**
         * All result items of npm-scripts.
         * @type {Array.<{name: string, code: (number|undefined)}>}
         */
        this.results = allResults
    }
}