bitoffdev commented on a change in pull request #2232:
URL: https://github.com/apache/hbase/pull/2232#discussion_r472180026



##########
File path: hbase-shell/src/main/ruby/shell.rb
##########
@@ -320,10 +323,20 @@ def eval_io(io)
       scanner = RubyLex.new
       scanner.set_input(io)
 
+      scanner.each_top_level_statement do |statement, linenum|
+        puts(workspace.evaluate(nil, statement, filename, linenum))
+      end
+      nil
+    end
+
+    ##
+    # Runs a block and logs exception from both Ruby and Java, optionally 
discarding the traceback
+    #
+    # @param [Boolean] hide_traceback if true, Exceptions will be converted to
+    #   a SystemExit so that the traceback is not printed
+    def self.exception_handler(hide_traceback)
       begin
-        scanner.each_top_level_statement do |statement, linenum|
-          puts(workspace.evaluate(nil, statement, 'stdin', linenum))
-        end
+        yield

Review comment:
       The `yield` ensures that whatever block is passed to `exception_handler` 
is executed within our begin/rescue, which is how we are able to catch and 
translate exceptions to a SystemExit to avoid printing the full traceback.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to