Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
module,errors: port module not found error to internal/errors
Keeping assigning error.code = 'MODULE_NOT_FOUND' for backwards
compatibility.
  • Loading branch information
rauno56 committed Mar 21, 2017
commit 46b4404d842fd89b0192759630756c9214fa3712
4 changes: 4 additions & 0 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,7 @@ module.exports = exports = {
// Note: Please try to keep these in alphabetical order
E('ERR_ASSERTION', (msg) => msg);
// Add new errors from here...
E('MODULE_NOT_FOUND', (request) => `Cannot find module '${request}'`);
E('ERR_PARSING_JSON', (filePath, message) => (
`Error parsing '${filePath}': ${message}`
));
4 changes: 2 additions & 2 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

const NativeModule = require('native_module');
const util = require('util');
const errors = require('internal/errors');
const internalModule = require('internal/module');
const vm = require('vm');
const assert = require('assert').ok;
Expand Down Expand Up @@ -482,8 +483,7 @@ Module._resolveFilename = function(request, parent, isMain) {
// look up the filename first, since that's the cache key.
var filename = Module._findPath(request, paths, isMain);
if (!filename) {
var err = new Error(`Cannot find module '${request}'`);
err.code = 'MODULE_NOT_FOUND';
const err = new errors.Error('MODULE_NOT_FOUND', request);
throw err;
}
return filename;
Expand Down