lib/input_sequencer.rb in markdown_exec-2.0.5 vs lib/input_sequencer.rb in markdown_exec-2.0.6
- old
+ new
@@ -18,10 +18,15 @@
def initialize(document_filename, initial_blocks = nil)
@document_filename = document_filename
@current_block = nil
@block_queue = initial_blocks
@debug = Env.env_bool('INPUT_SEQUENCER_DEBUG', default: false)
+ # rubocop:disable Style/RescueStandardError
+ rescue
+ pp $!, $@
+ exit 1
+ # rubocop:enable Style/RescueStandardError
end
# Merges the current menu state with the next, prioritizing the next state's values.
def self.merge_link_state(current, next_state)
MarkdownExec::LinkState.new(
@@ -52,10 +57,15 @@
end
# Orchestrates the flow of menu states and user interactions.
def run_yield(sym, *args, &block)
block.call sym, *args
+ # rubocop:disable Style/RescueStandardError
+ rescue
+ pp $!, $@
+ exit 1
+ # rubocop:enable Style/RescueStandardError
end
def bq_is_empty?
!@block_queue || @block_queue.empty?
end
@@ -79,13 +89,10 @@
exit_when_bq_empty = false
run_yield :display_menu, &block
choice = run_yield :user_choice, &block
- if choice.nil?
- raise 'Block not recognized.'
- break
- end
+ raise 'Block not recognized.' if choice.nil?
break if run_yield(:exit?, choice&.downcase, &block) # Exit loop and method to terminate the app
next_state = run_yield :execute_block, choice, &block
# imw_ins next_state, 'next_state'
return :break if next_state == :break