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 throw an error in the withdrawMoney Activity code.
In our case, this is just an error we are intentionally throwing, but this could just as easily be an internal service that isn't responding, a network outage, an application crashing, or more.
func WithdrawMoney(ctx context.Context, amount float64) (bool, error) {
return false, fmt.Errorf("Bank Service temporarily unavailable")
fmt.Printf("Successfully withdrawn $%.2f\n", amount)
return true, nil
}
func DepositMoney(ctx context.Context, amount float64) (bool, error) {
fmt.Printf("Successfully deposited $%.2f\n", amount)
return true, nil
}