Skip to content

Commit

Permalink
Add try / catch for non standard lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Neamar committed Nov 26, 2014
1 parent f4caf15 commit a638d04
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bin/bunyan
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a638d04

Please sign in to comment.