MCPcopy Create free account
hub / github.com/alphagov/notifications-api / InvalidRequest

Class InvalidRequest

app/errors.py:22–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20
21
22class InvalidRequest(Exception):
23 code = None
24 fields: list[dict] = []
25
26 def __init__(self, message: str, status_code: int) -> None:
27 super().__init__()
28 self.message = message
29 self.status_code = status_code
30
31 def to_dict(self) -> dict[str, Any]:
32 return {"result": "error", "message": self.message}
33
34 def to_dict_v2(self) -> dict[str, Any]:
35 """
36 Version 2 of the public api error response.
37 """
38 return {
39 "status_code": self.status_code,
40 "errors": [{"error": self.__class__.__name__, "message": self.message}],
41 }
42
43 def __str__(self) -> str:
44 return f"InvalidRequest: status_code={self.status_code}; message={self.message}"
45
46
47def register_errors(blueprint: Blueprint): # noqa: C901

Callers 15

process_mmg_responseFunction · 0.90
parse_tokenFunction · 0.90
validate_date_formatFunction · 0.90
one_click_unsubscribeFunction · 0.90
searchFunction · 0.90
update_organisationFunction · 0.90
archive_organisationFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected