Skip to content

Exception Handler Feature - #46

Merged
eadwinCode merged 13 commits into
mainfrom
exception_handler_feature
Dec 27, 2022
Merged

Exception Handler Feature#46
eadwinCode merged 13 commits into
mainfrom
exception_handler_feature

Conversation

@eadwinCode

Copy link
Copy Markdown
Collaborator

What Changed

  • Moved from function based exception handler to class based.
  • Changed EXCEPTION_HANDLER type from t.Dict[t.Union[int, Exception], t.Callable[[Request, Exception], Response] to t.List[IExceptionHandler]
  • Added an Interface that defined how to create an exception handler.
class IExceptionHandler(ABC, t.Iterable):
    exception_type_or_code: t.Optional[t.Union[int, t.Type[Exception]]] = None

    @abstractmethod
    async def catch(
        self, ctx: IExecutionContext, exc: t.Any
    ) -> t.Union[Response, t.Any]:  #
        pass
  • Added new ExceptionMiddleware and removed Starlette ExceptionMiddleware.
  • Added an exception service to manage the new exception middleware.

@codecov-commenter

codecov-commenter commented Dec 26, 2022

Copy link
Copy Markdown

Codecov Report

Merging #46 (c034e71) into main (876b3cb) will increase coverage by 0.24%.
The diff coverage is 94.61%.

@@            Coverage Diff             @@
##             main      #46      +/-   ##
==========================================
+ Coverage   91.66%   91.91%   +0.24%     
==========================================
  Files         137      141       +4     
  Lines        5041     5144     +103     
==========================================
+ Hits         4621     4728     +107     
+ Misses        420      416       -4     
Impacted Files Coverage Δ
ellar/core/exceptions/validation.py 100.00% <ø> (ø)
ellar/core/response/model/interface.py 100.00% <ø> (+16.66%) ⬆️
ellar/core/exceptions/handlers.py 87.17% <87.17%> (ø)
ellar/core/exceptions/callable_exceptions.py 88.88% <88.88%> (ø)
ellar/core/middleware/exceptions.py 88.88% <88.88%> (ø)
ellar/core/exceptions/base.py 91.30% <91.30%> (ø)
ellar/core/conf/mixins.py 89.87% <93.33%> (+0.32%) ⬆️
ellar/core/exceptions/interfaces.py 94.44% <94.44%> (ø)
ellar/common/decorators/controller.py 96.29% <100.00%> (ø)
ellar/common/decorators/exception.py 100.00% <100.00%> (ø)
... and 29 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@eadwinCode
eadwinCode merged commit 51a1639 into main Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants