Skip to content

Commit 73b3581

Browse files
Merge branch 'master' of github.com:SyntaxArc/ArchiPy
2 parents b463585 + f4d2766 commit 73b3581

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

archipy/helpers/utils/app_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def create_error_response(exception: BaseError) -> JSONResponse:
3939
BaseUtils.capture_exception(exception)
4040
# Default to internal server error if status code is not set
4141
status_code = (
42-
exception.http_status_code if exception.http_status_code else HTTPStatus.INTERNAL_SERVER_ERROR.value
42+
exception.http_status_code_value if exception.http_status_code_value else HTTPStatus.INTERNAL_SERVER_ERROR.value
4343
)
4444
return JSONResponse(status_code=status_code, content=exception.to_dict())
4545

archipy/models/dtos/base_protobuf_dto.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Any, ClassVar, Self
22

33
from archipy.models.dtos.base_dtos import BaseDTO
4+
from archipy.models.errors import InvalidEntityTypeError
45

56
try:
67
from google.protobuf.json_format import MessageToDict, ParseDict
@@ -32,6 +33,13 @@ def from_proto(cls, request: Message) -> Self:
3233
if cls._proto_class is None:
3334
raise NotImplementedError(f"{cls.__name__} is not mapped to a proto class.")
3435

36+
if not isinstance(request, cls._proto_class):
37+
raise InvalidEntityTypeError(
38+
message=f"{cls.__name__}.from_proto expected a different type of request.",
39+
expected_type=cls._proto_class.__name__,
40+
actual_type=type(request).__name__,
41+
)
42+
3543
input_data = MessageToDict(
3644
message=request,
3745
always_print_fields_with_no_presence=True,

0 commit comments

Comments
 (0)