Coverage for app/ddd/domain/error/group_error.py: 83%
24 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-15 01:44 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-15 01:44 +0000
1from enum import Enum
3from fastapi import status
5from app.core.base import BaseError
7# status.HTTP_400_BAD_REQUEST
8# status.HTTP_409_CONFLICT
9from app.ddd.domain import ErrorCode
12# Enumでエラー情報を定義
13class ErrorEnum(Enum):
14 INVALID_INPUT = (4001, status.HTTP_404_NOT_FOUND, "Invalid input provided")
15 USER_NOT_FOUND = (1404, status.HTTP_404_NOT_FOUND, "Group with ID {group_id} was not found.")
16 SERVER_ERROR = (5000, status.HTTP_404_NOT_FOUND, "Internal server error")
18class GroupNotFoundError(BaseError):
19 def __init__(self, group_id: str) -> None:
20 message = "Group with ID '{group_id}' was not found."
21 super().__init__(
22 error_code=ErrorCode.NOT_FOUND.str_value,
23 status_code=status.HTTP_404_NOT_FOUND,
24 description=message,
25 # group_id=group_id,
26 parameters={"group_id": group_id} # 修正
27 )
29class GroupDuplicationError(BaseError):
30 def __init__(self, group_id: str) -> None:
31 message = "Group with ID '{group_id}' already exists."
32 super().__init__(
33 error_code=ErrorCode.CONFLICT.str_value,
34 status_code=status.HTTP_409_CONFLICT,
35 description=message,
36 # group_id=group_id,
37 parameters={
38 "group_id": group_id,
39 "hoge": "huga",
40 } # 修正
41 )
43class GroupUpdateConflictError(BaseError):
44 def __init__(self, group_id: str) -> None:
45 message = "Group with ID '{group_id}' update conlict."
46 super().__init__(
47 error_code=ErrorCode.CONFLICT.str_value,
48 status_code=status.HTTP_409_CONFLICT,
49 description=message,
50 # group_id=group_id,
51 parameters={"group_id": group_id} # 修正
52 )
55# class GroupReportDuplicationError(BaseError):
56# def __init__(self, group_report_id: str) -> None:
57# message = "Group Report with ID '{group_report_id}' already exists."
58# super().__init__(
59# error_code=ErrorCode.CONFLICT.str_value,
60# status_code=status.HTTP_409_CONFLICT,
61# description=message,
62# group_report_id=group_report_id,
63# )
66class GroupAuthError(BaseError):
67 def __init__(self) -> None:
68 message = "auth error."
69 super().__init__(
70 error_code=ErrorCode.UNAUTHORIZED.str_value,
71 status_code=status.HTTP_401_UNAUTHORIZED,
72 description=message,
73 # group_id=group_id,
74 # parameters={"group_id": group_id} # 修正
75 )