Skip to content

Commit

Permalink
module: Set the error.code to 'MODULE_NOT_FOUND' when a bad path is g…
Browse files Browse the repository at this point in the history
…iven to require.

Fixes #2358.
  • Loading branch information
TooTallNate authored and koichik committed Dec 19, 2011
1 parent bb8f734 commit 3f987cd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ Module._resolveFilename = function(request, parent) {

var filename = Module._findPath(request, paths);
if (!filename) {
throw new Error("Cannot find module '" + request + "'");
var err = new Error("Cannot find module '" + request + "'");
err.code = 'MODULE_NOT_FOUND';
throw err;
}
id = filename;
return [id, filename];
Expand Down

0 comments on commit 3f987cd

Please sign in to comment.