Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Include a better toString() for missing module errors.

  • Loading branch information...
commit 1ef38733a186e53bc74f7e0b1fff3a5fa5f6d16e 1 parent 07617b9
@Mossop authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/toolkit/loader.js
View
7 lib/toolkit/loader.js
@@ -240,17 +240,18 @@ const load = iced(function load(loader, module) {
let { message, fileName, lineNumber } = error;
let stack = error.stack || Error().stack;
let frames = parseStack(stack).filter(isntLoaderFrame);
+ let toString = String(error);
// Note that `String(error)` where error is from subscript loader does
// not puts `:` after `"Error"` unlike regular errors thrown by JS code.
// If there is a JS stack then this error has already been handled by an
// inner module load.
- if (String(error) === "Error opening input stream (invalid filename?)" &&
- !error.stack) {
+ if (String(error) === "Error opening input stream (invalid filename?)") {
let caller = frames.slice(0).pop();
fileName = caller.fileName;
lineNumber = caller.lineNumber;
message = "Module `" + module.id + "` is not found at " + module.uri;
+ toString = message;
}
let prototype = typeof(error) === "object" ? error.constructor.prototype :
@@ -261,7 +262,7 @@ const load = iced(function load(loader, module) {
fileName: { value: fileName, writable: true, configurable: true },
lineNumber: { value: lineNumber, writable: true, configurable: true },
stack: { value: serializeStack(frames), writable: true, configurable: true },
- toString: { value: function() String(error), writable: true, configurable: true },
+ toString: { value: function() toString, writable: true, configurable: true },
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.