Skip to content

Commit d54e6e3

Browse files
Integrate exception translation in the ASF serialiser
1 parent 81352c9 commit d54e6e3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

localstack-core/localstack/aws/skeleton.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from collections.abc import Callable
44
from typing import Any, NamedTuple
55

6+
import moto.core.exceptions
67
from botocore import xform_name
78
from botocore.model import ServiceModel
89

@@ -151,6 +152,14 @@ def invoke(self, context: RequestContext) -> Response:
151152
raise NotImplementedError
152153

153154
return self.dispatch_request(serializer, context, instance)
155+
except moto.core.exceptions.ServiceException as moto_exc:
156+
# Translate Moto ServiceException into native one.
157+
# This gracefully handles errors when provider handlers invoke Moto methods directly.
158+
exc = CommonServiceException(
159+
code=moto_exc.code,
160+
message=moto_exc.message,
161+
)
162+
return self.on_service_exception(serializer, context, exc)
154163
except ServiceException as e:
155164
return self.on_service_exception(serializer, context, e)
156165
except NotImplementedError as e:

0 commit comments

Comments
 (0)