From 618cfce4fe849c391bec42f1c58fa0fe07d4265d Mon Sep 17 00:00:00 2001 From: Paul Vorbach Date: Fri, 20 Sep 2013 01:10:05 +0200 Subject: [PATCH] Refactor error handling Prefer returning long error messages instead of error codes only. --- pandoc.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pandoc.js b/pandoc.js index 6192b19..93ac14f 100644 --- a/pandoc.js +++ b/pandoc.js @@ -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); });