npm-run-all-error.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. 'use strict'
  8. // ------------------------------------------------------------------------------
  9. // Public Interface
  10. // ------------------------------------------------------------------------------
  11. /**
  12. * Error object with some additional info.
  13. */
  14. module.exports = class NpmRunAllError extends Error {
  15. /**
  16. * Constructor.
  17. *
  18. * @param {{name: string, code: number}} causeResult -
  19. * The result item of the npm-script which causes an error.
  20. * @param {Array.<{name: string, code: (number|undefined)}>} allResults -
  21. * All result items of npm-scripts.
  22. */
  23. constructor (causeResult, allResults) {
  24. super(`"${causeResult.task}" exited with ${causeResult.code}.`)
  25. /**
  26. * The name of a npm-script which exited with a non-zero code.
  27. * @type {string}
  28. */
  29. this.name = causeResult.name
  30. /**
  31. * The code of a npm-script which exited with a non-zero code.
  32. * This can be `undefined`.
  33. * @type {number}
  34. */
  35. this.code = causeResult.code
  36. /**
  37. * All result items of npm-scripts.
  38. * @type {Array.<{name: string, code: (number|undefined)}>}
  39. */
  40. this.results = allResults
  41. }
  42. }