# Error Handling

## Exceptions

### Raising them

You can raise exceptions with `raise` keyword.

```python
raise Exception("Some exception")

raise TypeError("Only integers")
```

And many other types.

### Catching them

Catch them with `try` and have multiple `except` statements for different exceptions.

```python
try:
    ...
except Exception as e:
    print(repr(e))
except:
    ...
else:
    ...
finally:
    ...
```

{% hint style="info" %}
The `else` block executes code when there is **no error.**

The `finally` block executes code **regardless if there were errors or not**.
{% endhint %}
