34 lines
766 B
Python
34 lines
766 B
Python
from typing import Union
|
|
|
|
from starlette import status
|
|
|
|
|
|
class MeDaCaException(Exception):
|
|
"""Webアプリの共通例外"""
|
|
pass
|
|
|
|
class NotAuthorizeException(MeDaCaException):
|
|
"""認証失敗の例外"""
|
|
pass
|
|
|
|
class JWTTokenVerifyException(MeDaCaException):
|
|
"""トークン検証失敗の例外"""
|
|
pass
|
|
|
|
class DBException(MeDaCaException):
|
|
"""DB関連の例外"""
|
|
pass
|
|
|
|
class UnexpectedException(MeDaCaException):
|
|
"""予期しない例外"""
|
|
|
|
# デフォルトを500エラーとする
|
|
default_status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
|
|
|
|
def __init__(
|
|
self,
|
|
detail: Union[str, dict],
|
|
) -> None:
|
|
self.status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
|
|
self.detail = detail
|