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.
export async withdrawMoney(amount: number): Promise<boolean> {
throw new Error('Bank service temporarily unavailable');
console.log(`Successfully withdrawn $${amount}`);
return true;
}
export async depositMoney(amount: number): Promise<boolean> {
console.log(`Successfully deposited $${amount}`);
return true;
}