# docstring-missing-exception (DOC501)#

Derived from the **pydoclint** linter.

This rule is unstable and in preview. The `--preview`

flag is required for use.

## What it does#

Checks for function docstrings that do not include documentation for all explicitly-raised exceptions.

## Why is this bad?#

If a function raises an exception without documenting it in its docstring, it can be misleading to users and/or a sign of incomplete documentation or refactors.

## Example#

```
def calculate_speed(distance: float, time: float) -> float:
"""Calculate speed as distance divided by time.
Args:
distance: Distance traveled.
time: Time spent traveling.
Returns:
Speed as distance divided by time.
"""
try:
return distance / time
except ZeroDivisionError as exc:
raise FasterThanLightError from exc
```

Use instead:

```
def calculate_speed(distance: float, time: float) -> float:
"""Calculate speed as distance divided by time.
Args:
distance: Distance traveled.
time: Time spent traveling.
Returns:
Speed as distance divided by time.
Raises:
FasterThanLightError: If speed is greater than the speed of light.
"""
try:
return distance / time
except ZeroDivisionError as exc:
raise FasterThanLightError from exc
```