home · contact · privacy
Use different exceptions throwing different HTTP codes for different cases.
[plomtask] / plomtask / exceptions.py
1 """
2 Whatever fits nowhere else, and/or is too small/trivial
3 to merit its own module at this point.
4 """
5
6
7 class HandledException(Exception):
8     """To identify Exceptions based on expected (if faulty) user behavior."""
9     http_code = 400
10
11
12 class BadFormatException(HandledException):
13     """To identify Exceptions on malformed inputs."""
14     http_code = 401
15
16
17 class NotFoundException(HandledException):
18     """To identify Exceptions on unsuccessful queries."""
19     http_code = 404