Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit 3f987cd

Browse files
TooTallNatekoichik
authored andcommittedDec 19, 2011
module: Set the error.code to 'MODULE_NOT_FOUND' when a bad path is given to require.
Fixes #2358.
·
1 parent bb8f734 commit 3f987cd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎lib/module.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,9 @@ Module._resolveFilename = function(request, parent) {
331331

332332
var filename = Module._findPath(request, paths);
333333
if (!filename) {
334-
throw new Error("Cannot find module '" + request + "'");
334+
var err = new Error("Cannot find module '" + request + "'");
335+
err.code = 'MODULE_NOT_FOUND';
336+
throw err;
335337
}
336338
id = filename;
337339
return [id, filename];

0 commit comments

Comments
 (0)
This repository has been archived.