Skip to main content

Let's Throw an Error!

Now let's see Temporal in action!

We’ll now look at how Temporal retries your code. We’ll intentionally raise an error in the WithdrawMoney Activity code.

In our case, this is just an error we are intentionally raising, but this could just as easily be an internal service that isn't responding, a network outage, an application crashing, or more.

require 'temporalio/activity'

class WithdrawMoneyActivity < Temporalio::Activity::Definition
def execute(amount)
raise StandardError, 'Bank service temporarily unavailable'
puts "Successfully withdrawn $#{amount}"
true
end
end

class DepositMoneyActivity < Temporalio::Activity::Definition
def execute(amount)
puts "Successfully deposited $#{amount}"
true
end
end
6 / 9