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 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.

Activity Code
export async function withdrawMoney(amount: number): Promise<void> {
throw new Error('Bank service temporarily unavailable');
console.log(`Successfully withdrawn $${amount}`);
}
export async function depositMoney(amount: number): Promise<void> {
console.log(`Successfully deposited $${amount}`);
}
7 / 10