From 116444d01dd8bd003f570361dd38d8e439c63f33 Mon Sep 17 00:00:00 2001 From: Ville Lautanala Date: Wed, 25 Sep 2019 21:17:33 +0300 Subject: [PATCH] Handle unexpected error messages better --- lib/uglifier.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/uglifier.rb b/lib/uglifier.rb index f244c5e..35925af 100644 --- a/lib/uglifier.rb +++ b/lib/uglifier.rb @@ -267,6 +267,8 @@ def format_lines(lines, options) end def context_lines_message(source, line_number, column) + return if line_number.nil? + line_index = line_number - 1 lines = source.split("\n") @@ -280,7 +282,7 @@ def context_lines_message(source, line_number, column) def error_message(result, options) err = result['error'] - harmony_msg = harmony? ? '' : harmony_error_message(err['message']) + harmony_msg = harmony? ? '' : harmony_error_message(err['message'].to_s) src_ctx = context_lines_message(options[:source], err['line'], err['col']) "#{err['message']}#{harmony_msg}\n#{src_ctx}" end