1 | /**
|
2 | * @module npm-run-all-error
|
3 | * @author Toru Nagashima
|
4 | * @copyright 2016 Toru Nagashima. All rights reserved.
|
5 | * See LICENSE file in root directory for full license.
|
6 | */
|
7 |
|
8 |
|
9 | //------------------------------------------------------------------------------
|
10 | // Public Interface
|
11 | //------------------------------------------------------------------------------
|
12 |
|
13 | /**
|
14 | * Error object with some additional info.
|
15 | */
|
16 | module.exports = class NpmRunAllError extends Error {
|
17 | /**
|
18 | * Constructor.
|
19 | *
|
20 | * @param {{name: string, code: number}} causeResult -
|
21 | * The result item of the npm-script which causes an error.
|
22 | * @param {Array.<{name: string, code: (number|undefined)}>} allResults -
|
23 | * All result items of npm-scripts.
|
24 | */
|
25 | constructor(causeResult, allResults) {
|
26 | super(`"${causeResult.task}" exited with ${causeResult.code}.`)
|
27 |
|
28 | /**
|
29 | * The name of a npm-script which exited with a non-zero code.
|
30 | * @type {string}
|
31 | */
|
32 | this.name = causeResult.name
|
33 |
|
34 | /**
|
35 | * The code of a npm-script which exited with a non-zero code.
|
36 | * This can be `undefined`.
|
37 | * @type {number}
|
38 | */
|
39 | this.code = causeResult.code
|
40 |
|
41 | /**
|
42 | * All result items of npm-scripts.
|
43 | * @type {Array.<{name: string, code: (number|undefined)}>}
|
44 | */
|
45 | this.results = allResults
|
46 | }
|
47 | }
|