gulpjs / gulp-cli

Command Line Interface for gulp.
MIT License
401 stars 106 forks source link

format-error.js: Prefer `e.error.message` if available #173

Closed xkr47 closed 6 years ago

xkr47 commented 6 years ago

Previously when using e.error and it was an object, we got just an "[object Object]" message in the resulting Error object (and error message in terminal). With this patch instead when there is a message property inside e.error, use that to get a better error report, and falling back to old behaviour in other cases.

sttk commented 6 years ago

@xkr47 Thank you for this PR, but is there a test for verifying this patch? Or are there any examples to reproduce to outputting "[object Object]" message?

phated commented 6 years ago

Sounds like your toString methods are wrong?

xkr47 commented 6 years ago

You are right, although it was not exactly "our" toString :)

function Webpack(done) {
  const run        = require('parallel-webpack').run
  const configPath = require.resolve('./webpack/build.js')

  run(configPath, {
    watch               : rawVersion,
    maxRetries          : 0,
    stats               : false,
    maxConcurrentWorkers: 3
  }, done)
}

Changed that next-last line to instead do:

  }, (err) => done(err && err.message || err))

and now I get errors nicely passed through!

Sorry for the inconvenience. I did not investigate the problem far enough.