Skip to content

Commit

Permalink
Only abort if the callback chain has been halted
Browse files Browse the repository at this point in the history
  • Loading branch information
hopsoft committed Jan 4, 2024
1 parent acbaad6 commit d1a6410
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/turbo_boost/commands/command_callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,13 @@ def callback_options(options)
halt = false # CONTINUE the callback chain
end

# `throw :abort` was invoked
command.send :aborted!,
TurboBoost::Commands::AbortError.new(command: command)
if halt # callback chain halted, meaning `throw` was invoked in a callback
command.send :aborted!, TurboBoost::Commands::AbortError.new(command: command)
end
rescue UncaughtThrowError => error
# `throw` was invoked without :abort
message = "Please use `throw :abort` to abort a command."
command.send :aborted!,
TurboBoost::Commands::AbortError.new(message, command: command, cause: error)
command.send :aborted!, TurboBoost::Commands::AbortError.new(message, command: command, cause: error)
rescue => error
# unxpected error in callback
command.send :errored!, error
Expand Down

0 comments on commit d1a6410

Please sign in to comment.