Skip to content

Commit

Permalink
Merge pull request #573 from JeroenVinke/fix/error-reporting
Browse files Browse the repository at this point in the history
fix(all): improved error reporting
  • Loading branch information
EisenbergEffect committed Mar 31, 2017
2 parents ea0d056 + 4060148 commit 84952de
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/build/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,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;
});
}

Expand Down
20 changes: 20 additions & 0 deletions lib/build/bundled-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
Expand Down Expand Up @@ -149,6 +164,11 @@ exports.BundledSource = class {
newItem.deps = result.deps;
}
}
})
.catch(e => {
console.log('Error occurred while tracing');
console.log(e);
throw e;
});
}

Expand Down
10 changes: 10 additions & 0 deletions lib/build/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ exports.Bundler = class {
}

return description;
})
.catch(e => {
console.log(`Unable to analyze ${(dependency.name || dependency)}`);
console.log(e);
throw e;
});
}

Expand All @@ -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;
});
}

Expand Down
5 changes: 5 additions & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,8 @@ function determineWorkingDirectory(dir) {
.then(() => dir)
.catch(() => determineWorkingDirectory(parent));
}

process.on('unhandledRejection', (reason) => {
console.log('Uncaught promise rejection:');
console.log(reason);
});

0 comments on commit 84952de

Please sign in to comment.