Permalink
Browse files

Refactor error handling

Prefer returning long error messages instead of error codes only.
  • Loading branch information...
1 parent b9e959b commit 618cfce4fe849c391bec42f1c58fa0fe07d4265d @pvorb committed Sep 19, 2013
Showing with 7 additions and 3 deletions.
  1. +7 −3 pandoc.js
View
@@ -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);
});

0 comments on commit 618cfce

Please sign in to comment.