---
title: Miscellaneous
description: "Various niche examples which don't yet have a dedicated page but are useful and interesting nonetheless."
---

Various niche examples which don't yet have a dedicated page but are useful and interesting nonetheless.

## How to throw errors

The `throw(){:tact}` function in a contract is useful when we don't know how often to perform a specific action.

It allows intentional exception or error handling, which leads to the termination of the current transaction and reverts any state changes made during that transaction.

```tact
let number: Int = 198;

// the error will be triggered anyway
try {
    throw(36);
} catch (exitCode) {}

// the error will be triggered only if the number is greater than 50
try {
    throwIf(35, number > 50);
} catch (exitCode) {}

// the error will be triggered only if the number is NOT EQUAL to 198
try {
    throwUnless(39, number == 198);
} catch (exitCode) {}
```

:::note[Useful links:]

  [`throw(){:tact}` in Core library](/ref/core-debug#throw)\
  [Errors in Tact-By-Example](https://tact-by-example.org/03-errors)

:::

:::tip[Hey there!]

  Didn't find your favorite example of working with something niche? Have cool implementations in mind? [Contributions are welcome!](https://github.com/tact-lang/tact/issues)

:::
