include stack trace when printing error message if a seeder fails #411
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was building seeders for a new project and found that the error message printed did not include enough information (like which file caused the problem). This PR enhances the error message printed in the .catch(function(e) { }) handlers so include the stack trace. As an example, an exception running db:seed:undo now looks like the following, and I can know exactly where the error is.
== 20170110190423-admin-act: reverting =======
Seed file failed with error: Cannot read property 'getProfile' of null TypeError: Cannot read property 'getProfile' of null
at Model. (/usr/src/app/server/db/seeders/20170110190423-admin-act.js:36:24)
at Model.tryCatcher (/usr/src/app/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/usr/src/app/node_modules/bluebird/js/release/promise.js:510:31)
at Promise._settlePromise (/usr/src/app/node_modules/bluebird/js/release/promise.js:567:18)
at Promise._settlePromise0 (/usr/src/app/node_modules/bluebird/js/release/promise.js:612:10)
at Promise._settlePromises (/usr/src/app/node_modules/bluebird/js/release/promise.js:691:18)
at Async._drainQueue (/usr/src/app/node_modules/bluebird/js/release/async.js:138:16)
at Async._drainQueues (/usr/src/app/node_modules/bluebird/js/release/async.js:148:10)
at Immediate.Async.drainQueues (/usr/src/app/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:649:20)
at tryOnImmediate (timers.js:622:5)
at processImmediate [as _immediateCallback] (timers.js:594:5)