Bases: OptimadeHTTPException
400 Bad Request
Source code in optimade/exceptions.py55
56
57
58
59 | class BadRequest(OptimadeHTTPException):
"""400 Bad Request"""
status_code: int = 400
title: str = "Bad Request"
|
Bases: OptimadeHTTPException
403 Forbidden
Source code in optimade/exceptions.py69
70
71
72
73 | class Forbidden(OptimadeHTTPException):
"""403 Forbidden"""
status_code: int = 403
title: str = "Forbidden"
|
Bases: OptimadeHTTPException
500 Internal Server Error
Source code in optimade/exceptions.py90
91
92
93
94 | class InternalServerError(OptimadeHTTPException):
"""500 Internal Server Error"""
status_code: int = 500
title: str = "Internal Server Error"
|
Bases: OptimadeHTTPException
404 Not Found
Source code in optimade/exceptions.py76
77
78
79
80 | class NotFound(OptimadeHTTPException):
"""404 Not Found"""
status_code: int = 404
title: str = "Not Found"
|
Bases: OptimadeHTTPException
501 Not Implemented
Source code in optimade/exceptions.py 97
98
99
100
101 | class NotImplementedResponse(OptimadeHTTPException):
"""501 Not Implemented"""
status_code: int = 501
title: str = "Not Implemented"
|
Bases: Exception, ABC
This abstract class can be subclassed to define HTTP responses with the desired status codes, and detailed error strings to represent in the JSON:API error response.
This class closely follows the starlette.HTTPException without requiring it as a dependency, so that such errors can also be raised from within client code.
Attributes:
| status_code | int |
The HTTP status code accompanying this exception. |
| title | str |
A descriptive title for this exception. |
| detail | str | None |
An optional string containing the details of the error. |
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 | class OptimadeHTTPException(Exception, ABC):
"""This abstract class can be subclassed to define
HTTP responses with the desired status codes, and
detailed error strings to represent in the JSON:API
error response.
This class closely follows the `starlette.HTTPException` without
requiring it as a dependency, so that such errors can also be
raised from within client code.
Attributes:
status_code: The HTTP status code accompanying this exception.
title: A descriptive title for this exception.
detail: An optional string containing the details of the error.
"""
status_code: int
title: str
detail: str | None = None
headers: dict[str, Any] | None = None
def __init__(self, detail: str | None = None, headers: dict | None = None) -> None:
if self.status_code is None:
raise AttributeError(
"HTTPException class {self.__class__.__name__} is missing required `status_code` attribute."
)
self.detail = detail
self.headers = headers
def __str__(self) -> str:
return self.detail if self.detail is not None else self.__repr__()
def __repr__(self) -> str:
class_name = self.__class__.__name__
return f"{class_name}(status_code={self.status_code!r}, detail={self.detail!r})"
|
Bases: OptimadeHTTPException
422 Unprocessable Entity
Source code in optimade/exceptions.py83
84
85
86
87 | class UnprocessableEntity(OptimadeHTTPException):
"""422 Unprocessable Entity"""
status_code: int = 422
title: str = "Unprocessable Entity"
|
Bases: OptimadeHTTPException
553 Version Not Supported
Source code in optimade/exceptions.py62
63
64
65
66 | class VersionNotSupported(OptimadeHTTPException):
"""553 Version Not Supported"""
status_code: int = 553
title: str = "Version Not Supported"
|