Skip to content

Commit

Permalink
Better error messages on load/compile fail
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed Dec 13, 2011
1 parent 0084cbd commit abf773a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions lib/node.io/processor.js
Expand Up @@ -298,8 +298,7 @@ Processor.prototype.loadJob = function (job, options, callback) {

//Now that require.paths has gone away we have to jump through hoops.

var tryPaths = [process.cwd() + '/', '']
, notFound = /Cannot find/;
var tryPaths = [process.cwd() + '/', ''];

for (var jobPath, i = 0; i < tryPaths.length; i++) {
jobPath = tryPaths[i] + job;
Expand All @@ -308,12 +307,12 @@ Processor.prototype.loadJob = function (job, options, callback) {
this.processJob(job, require(jobPath), options, callback);
return;
} catch (e) {
if (notFound.test(e.message)) {
if (new RegExp("Cannot find module '"+jobPath+"'").test(e.message)) {
this.status('Failed to load require(\'' + jobPath + '\') - not found', 'debug');
} else {
this.status('Error: ' + e.message, 'debug');
this.status('Trace: ' + JSON.stringify(e), 'debug');
return callback('Failed to load job "' + job + '". Please check that the job exists and compiles correctly.');
this.status('Error: Failed to load job "' + job + '". Please check that the job exists and compiles correctly.', 'error');
throw e;
return callback('load error');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{ "name" : "node.io",
"description" : "A distributed data scraping and processing framework",
"version" : "0.4.4",
"version" : "0.4.5",
"homepage" : "http://github.com/chriso/node.io",
"keywords" : ["data","mapreduce","map","reduce","scraping","html","parsing","parse","scrape","process","processing","data"],
"author" : "Chris O'Hara <cohara87@gmail.com>",
Expand Down

0 comments on commit abf773a

Please sign in to comment.