Skip to content

Commit

Permalink
Improve error logging (#8155)
Browse files Browse the repository at this point in the history
Improve error logging

Co-authored-by: Norbert de Langen <ndelangen@me.com>
  • Loading branch information
ndelangen authored and shilman committed Oct 7, 2019
1 parent 169ddd5 commit 0b7af6e
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions lib/core/src/server/build-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,15 @@ export async function buildDevStandalone(options) {
// this is a weird bugfix, somehow 'node-pre-gyp' is polluting the npmLog header
npmLog.heading = '';

if (error instanceof Error) {
if (error.error) {
logger.error(error.error);
} else if (error.stats && error.stats.compilation.errors) {
error.stats.compilation.errors.forEach(e => logger.plain(e));
} else {
logger.error(error);
}
}
logger.line();
logger.warn(
error.close
Expand All @@ -337,25 +346,13 @@ export async function buildDevStandalone(options) {
Fix the error below and restart storybook.
`
: stripIndents`
Broken build, fix the error below.
Broken build, fix the error above.
You may need to refresh the browser.
`
);
logger.line();
if (error instanceof Error) {
if (error.error) {
logger.error(error.error);
} else if (error.stats && error.stats.compilation.errors) {
error.stats.compilation.errors.forEach(e => logger.plain(e));
} else {
logger.error(error);
}

if (error.close) {
process.exit(1);
}
}
if (options.smokeTest) {

if (options.smokeTest || error && error.close) {
process.exit(1);
}
}
Expand Down

0 comments on commit 0b7af6e

Please sign in to comment.