lib/synvert/cli.rb in synvert-1.2.5 vs lib/synvert/cli.rb in synvert-1.2.6

- old
+ new

@@ -58,10 +58,12 @@ rescue Parser::SyntaxError => e puts "Syntax error: #{e.message}" puts "file #{e.diagnostic.location.source_buffer.name}" puts "line #{e.diagnostic.location.line}" false + rescue StandardError + false end private # Run OptionParser to parse arguments. @@ -244,15 +246,25 @@ affected_files: rewriter.affected_files.union(rewriter.sub_snippets.sum(Set.new, &:affected_files)).to_a, warnings: rewriter.warnings.union(rewriter.sub_snippets.sum([], &:warnings)) } puts JSON.generate(output) end + rescue StandardError => e + if plain_output? + puts "Error: #{e.message}" + else + puts JSON.generate(error: e.message) + end + raise end # test a snippet def test_snippet(rewriter) results = rewriter.test puts JSON.generate(results) + rescue StandardError => e + puts JSON.generate(error: e.message) + raise end # execute snippet def execute_snippet(execute_command) rewriter = eval_snippet_name_by_input(STDIN.read)