home · contact · privacy
Use different exceptions throwing different HTTP codes for different cases.
[plomtask] / plomtask / exceptions.py
diff --git a/plomtask/exceptions.py b/plomtask/exceptions.py
new file mode 100644 (file)
index 0000000..379ae9f
--- /dev/null
@@ -0,0 +1,19 @@
+"""
+Whatever fits nowhere else, and/or is too small/trivial
+to merit its own module at this point.
+"""
+
+
+class HandledException(Exception):
+    """To identify Exceptions based on expected (if faulty) user behavior."""
+    http_code = 400
+
+
+class BadFormatException(HandledException):
+    """To identify Exceptions on malformed inputs."""
+    http_code = 401
+
+
+class NotFoundException(HandledException):
+    """To identify Exceptions on unsuccessful queries."""
+    http_code = 404