From a638d0474d77243b4ebb8787886a674fdc247a07 Mon Sep 17 00:00:00 2001 From: Neamar Date: Tue, 25 Nov 2014 19:30:28 +0100 Subject: [PATCH] Add try / catch for non standard lines --- bin/bunyan | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/bunyan b/bin/bunyan index 995a9da8..d9777e23 100755 --- a/bin/bunyan +++ b/bin/bunyan @@ -1069,7 +1069,16 @@ function emitRecord(rec, line, opts, stylize) { rec._cS = stylize.start; // Shortcut for "colorEnd" rec._cE = stylize.end; - emit(opts.template ? opts.template(rec) : 'No template defined. Use --template.' +'\n'); + + var out; + try { + out = opts.template ? opts.template(rec) : 'No template defined. Use --template.'; + } + catch(e) { + // Unprocessable line, display default + return emit(line + '\n'); + } + emit(out + '\n'); break; default: throw new Error('unknown output mode: '+opts.outputMode);