Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reserve error stack information #2871

Merged
merged 4 commits into from May 27, 2019
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/ModuleLoader.ts
Expand Up @@ -307,11 +307,21 @@ export class ModuleLoader {
)
.catch((err: Error) => {
timeEnd('load modules', 3);
let msg = `Could not load ${id}`;
if (importer) msg += ` (imported by ${importer})`;
const error = new Error('~');

msg += `: ${err.message}`;
throw new Error(msg);
let surfix = error.stack || '';
surfix = surfix.replace('Error: ~', '');

let prefix = `Could not load ${id}`;
if (importer) prefix += ` (imported by ${importer})`;
prefix += ':\n';

const message = err.message || '';
const stack = err.stack || '';
error.message = prefix + message;
error.stack = prefix + stack + surfix;

throw error;
})
.then(source => {
timeEnd('load modules', 3);
Expand Down