Skip to content

Commit

Permalink
Refactor error handling
Browse files Browse the repository at this point in the history
Prefer returning long error messages instead of error codes only.
  • Loading branch information
pvorb committed Sep 19, 2013
1 parent b9e959b commit 618cfce
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pandoc.js
Expand Up @@ -25,10 +25,14 @@ function pdc(src, from, to, opt, cb) {
});

pandoc.on('exit', function (code) {
if (code != 0 && !err)
return cb(new Error('pandoc exited with code '+code+'.'));
var msg = '';
if (code !== 0)
msg += 'pandoc exited with code '+code+(error ? ': ' : '.');
if (error)
return cb(new Error(error));
msg += error;

if (msg)
return cb(new Error(msg));

cb(null, result);
});
Expand Down

0 comments on commit 618cfce

Please sign in to comment.