You've already forked hotpocket
BTHLABS-61: Service layer refactoring
A journey to fix `ValidationError` in Pocket imports turned service layer refactoring :D
This commit is contained in:
28
services/packages/soa/hotpocket_soa/exceptions/frontend.py
Normal file
28
services/packages/soa/hotpocket_soa/exceptions/frontend.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import annotations
|
||||
|
||||
import typing
|
||||
|
||||
from .backend import BackendServiceError
|
||||
|
||||
|
||||
class SOAError(Exception):
|
||||
def __init__(self, code: int, message: str, *args):
|
||||
super().__init__(code, message, *args)
|
||||
self.code = code
|
||||
self.message = message
|
||||
|
||||
self.data: typing.Any = None
|
||||
if len(args) > 0:
|
||||
self.data = args[0]
|
||||
|
||||
@classmethod
|
||||
def from_backend_error(cls: type[typing.Self], exception: BackendServiceError) -> typing.Self:
|
||||
result = cls(
|
||||
exception.CODE.value,
|
||||
exception.message,
|
||||
exception.data,
|
||||
)
|
||||
result.__cause__ = exception
|
||||
|
||||
return result
|
||||
Reference in New Issue
Block a user