lib/byebug/processors/command_processor.rb in byebug-6.0.2 vs lib/byebug/processors/command_processor.rb in byebug-7.0.0

- old
+ new

@@ -24,11 +24,11 @@ @proceed = false @prev_line = nil end def interface - @interface ||= context.class.interface + @interface ||= Context.interface end def printer @printer ||= Printers::Plain.new end @@ -66,18 +66,20 @@ end def at_tracing puts "Tracing: #{context.full_location}" - run_auto_commands(2) + run_auto_cmds(2) end def at_line process_commands end - def at_return + def at_return(return_value) + puts "Return value is: #{safe_inspect(return_value)}" + process_commands end # # Let the execution continue @@ -106,26 +108,28 @@ '(byebug) ' end private - def auto_commands_for(run_level) + def auto_cmds_for(run_level) command_list.select { |cmd| cmd.always_run >= run_level } end # # Run permanent commands. # - def run_auto_commands(run_level) - auto_commands_for(run_level).each { |cmd| cmd.new(self).execute } + def run_auto_cmds(run_level) + safely do + auto_cmds_for(run_level).each { |cmd| cmd.new(self).execute } + end end def before_repl @proceed = false @prev_line = nil - run_auto_commands(1) + run_auto_cmds(1) interface.autorestore end def after_repl interface.autosave @@ -150,13 +154,19 @@ # # Instantiates a command matching the input and runs it. If a matching # command is not found, it evaluates the unknown input. # def run_cmd(input) - command = command_list.match(input) - return command.new(self, input).execute if command + safely do + command = command_list.match(input) + return command.new(self, input).execute if command - puts thread_safe_eval(input) + puts safe_inspect(thread_safe_eval(input)) + end + end + + def safely + yield rescue => e errmsg(e.message) end end end