hotpocket/services/packages/soa/hotpocket_soa/exceptions/frontend.py
Tomek Wójcik 8b86145519 BTHLABS-61: Service layer refactoring
A journey to fix `ValidationError` in Pocket imports turned service
layer refactoring :D
2025-10-12 20:54:00 +02:00

29 lines
702 B
Python

# -*- 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