mirror of
https://github.com/mikeckennedy/fastapi-chameleon.git
synced 2025-08-06 17:29:44 +08:00

Data templating is now possible with `generic_error` in a way that does not break compatibility. May add a readme update in the future to specify new behavior. Signed-off-by: Ayzee Patton <vlpatton@vlpatton.gay>
25 lines
836 B
Python
25 lines
836 B
Python
from typing import Optional
|
|
|
|
|
|
class FastAPIChameleonException(Exception):
|
|
pass
|
|
|
|
|
|
class FastAPIChameleonNotFoundException(FastAPIChameleonException):
|
|
def __init__(self, message: Optional[str] = None, four04template_file: str = 'errors/404.pt'):
|
|
super().__init__(message)
|
|
|
|
self.template_file: str = four04template_file
|
|
self.message: Optional[str] = message
|
|
|
|
|
|
class FastAPIChameleonGenericException(FastAPIChameleonException):
|
|
def __init__(self, template_file: str, status_code: int,
|
|
message: Optional[str] = None, template_data: Optional[dict] = None):
|
|
super().__init__(message)
|
|
|
|
self.template_file: str = template_file
|
|
self.status_code: int = status_code
|
|
self.message: Optional[str] = message
|
|
self.template_data: Optional[dict] = template_data
|