From 4060148086291b68f85d40504e099d24cd5a2c59 Mon Sep 17 00:00:00 2001 From: JeroenVinke Date: Thu, 30 Mar 2017 12:45:49 +0200 Subject: [PATCH] fix(all): improved error reporting closes https://github.com/aurelia/cli/issues/504 --- lib/build/bundle.js | 15 ++++++++++++++- lib/build/bundled-source.js | 20 ++++++++++++++++++++ lib/build/bundler.js | 10 ++++++++++ lib/cli.js | 5 +++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/lib/build/bundle.js b/lib/build/bundle.js index cbcf3bff1..e4f39fcb8 100644 --- a/lib/build/bundle.js +++ b/lib/build/bundle.js @@ -259,9 +259,22 @@ exports.Bundle = class { this.requiresBuild = false; if (mapContents) { - return fs.writeFile(path.posix.join(platform.output, mapFileName), mapContents); + return fs.writeFile(path.posix.join(platform.output, mapFileName), mapContents) + .catch(e => { + console.log(`Unable to write the sourcemap to ${path.posix.join(platform.output, mapFileName)}`); + }); } + }) + .catch(e => { + console.log(`Unable to write the bundle to ${path.posix.join(platform.output, bundleFileName)}`); + console.log(e); + throw e; }); + }) + .catch(e => { + console.log('Failed to write the bundle'); + console.log(e); + throw e; }); } diff --git a/lib/build/bundled-source.js b/lib/build/bundled-source.js index 71811ffcf..924f1cf69 100644 --- a/lib/build/bundled-source.js +++ b/lib/build/bundled-source.js @@ -106,6 +106,7 @@ exports.BundledSource = class { }, that.getInclusion(location)); } catch (e) { console.log(`File not found or not accessible: ${location}. Requested by ${modulePath}`); + console.log(e); } return contents; @@ -122,6 +123,20 @@ exports.BundledSource = class { loaderConfig ).then(traceResult => { let traced = traceResult.traced; + let errors = traceResult.errors; + let warnings = traceResult.warnings; + + if (errors) { + for (let i = 0; i < errors.length; i++) { + console.log(`Trace error: ${errors[i]}`); + } + } + + if (warnings) { + for (let i = 0; i < warnings.length; i++) { + console.log(`Trace warning: ${warnings[i]}`); + } + } for (let i = 0, ii = traced.length; i < ii; ++i) { let result = traceResult.traced[i]; @@ -149,6 +164,11 @@ exports.BundledSource = class { newItem.deps = result.deps; } } + }) + .catch(e => { + console.log('Error occurred while tracing'); + console.log(e); + throw e; }); } diff --git a/lib/build/bundler.js b/lib/build/bundler.js index 22b38f86d..11f7070c6 100644 --- a/lib/build/bundler.js +++ b/lib/build/bundler.js @@ -171,6 +171,11 @@ exports.Bundler = class { } return description; + }) + .catch(e => { + console.log(`Unable to analyze ${(dependency.name || dependency)}`); + console.log(e); + throw e; }); } @@ -193,6 +198,11 @@ exports.Bundler = class { //Order the bundles so that the bundle containing the config is processed last. let configTargetBundleIndex = this.bundles.findIndex(x => x.config.name === this.loaderOptions.configTarget); this.bundles.splice(this.bundles.length, 0, this.bundles.splice(configTargetBundleIndex, 1)[0]); + }) + .catch(e => { + console.log('Failed to do transforms'); + console.log(e); + throw e; }); } diff --git a/lib/cli.js b/lib/cli.js index b5bd98c0d..0a1d1b567 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -113,3 +113,8 @@ function determineWorkingDirectory(dir) { .then(() => dir) .catch(() => determineWorkingDirectory(parent)); } + +process.on('unhandledRejection', (reason) => { + console.log('Uncaught promise rejection:'); + console.log(reason); +});