Browse files

merged the context error patches

  • Loading branch information...
1 parent 0d09991 commit 8408e6e8902b4bec8c859d606f53366e42058378 @substack committed Nov 27, 2013
Showing with 13 additions and 12 deletions.
  1. +2 −2 lib/async.js
  2. +2 −2 lib/sync.js
  3. +4 −4 test/mock.js
  4. +5 −4 test/resolver.js
View
4 lib/async.js
@@ -33,15 +33,15 @@ module.exports = function resolve (x, opts, cb) {
else loadAsDirectory(path.resolve(y, x), function (err, d, pkg) {
if (err) cb(err)
else if (d) cb(null, d, pkg)
- else cb(new Error("Cannot find module '" + x + "'"))
+ else cb(new Error("Cannot find module '" + x + "' from '" + y + "'"))
})
});
}
else loadNodeModules(x, y, function (err, n, pkg) {
if (err) cb(err)
else if (n) cb(null, n, pkg)
else if (core[x]) return cb(null, x);
- else cb(new Error("Cannot find module '" + x + "'"))
+ else cb(new Error("Cannot find module '" + x + "' from '" + y + "'"))
});
function loadAsFile (x, pkg, cb) {
View
4 lib/sync.js
@@ -28,8 +28,8 @@ module.exports = function (x, opts) {
}
if (core[x]) return x;
-
- throw new Error("Cannot find module '" + x + "'");
+
+ throw new Error("Cannot find module '" + x + "' from '" + y + "'");
function loadAsFileSync (x) {
if (isFile(x)) {
View
8 test/mock.js
@@ -33,11 +33,11 @@ test('mock', function (t) {
});
resolve('baz', opts('/foo/bar'), function (err, res) {
- t.equal(err.message, "Cannot find module 'baz'");
+ t.equal(err.message, "Cannot find module 'baz' from '/foo/bar'");
});
resolve('../baz', opts('/foo/bar'), function (err, res) {
- t.equal(err.message, "Cannot find module '../baz'");
+ t.equal(err.message, "Cannot find module '../baz' from '/foo/bar'");
});
});
@@ -74,11 +74,11 @@ test('mock from package', function (t) {
});
resolve('baz', opts('/foo/bar'), function (err, res) {
- t.equal(err.message, "Cannot find module 'baz'");
+ t.equal(err.message, "Cannot find module 'baz' from '/foo/bar'");
});
resolve('../baz', opts('/foo/bar'), function (err, res) {
- t.equal(err.message, "Cannot find module '../baz'");
+ t.equal(err.message, "Cannot find module '../baz' from '/foo/bar'");
});
});
View
9 test/resolver.js
@@ -1,3 +1,4 @@
+var path = require('path');
var test = require('tap').test;
var resolve = require('../');
@@ -30,7 +31,7 @@ test('async foo', function (t) {
});
resolve('foo', { basedir : dir }, function (err) {
- t.equal(err.message, "Cannot find module 'foo'");
+ t.equal(err.message, "Cannot find module 'foo' from '" + path.resolve(dir) + "'");
});
});
@@ -190,7 +191,7 @@ test('cup', function (t) {
resolve('./cup', { basedir : dir, extensions : [ '.js' ] },
function (err, res) {
- t.equal(err.message, "Cannot find module './cup'");
+ t.equal(err.message, "Cannot find module './cup' from '" + path.resolve(dir) + "'");
});
});
@@ -233,11 +234,11 @@ test('other path', function (t) {
});
resolve('root', { basedir : dir, }, function (err, res) {
- t.equal(err.message, "Cannot find module 'root'");
+ t.equal(err.message, "Cannot find module 'root' from '" + path.resolve(dir) + "'");
});
resolve('zzz', { basedir : dir, paths: [otherDir] }, function (err, res) {
- t.equal(err.message, "Cannot find module 'zzz'");
+ t.equal(err.message, "Cannot find module 'zzz' from '" + path.resolve(dir) + "'");
});
});

0 comments on commit 8408e6e

Please sign in to comment.