File tree Expand file tree Collapse file tree 2 files changed +12
-14
lines changed
localstack-core/localstack/aws/handlers Expand file tree Collapse file tree 2 files changed +12
-14
lines changed Original file line number Diff line number Diff line change 11"""Handlers for logging."""
22
3- import contextlib
4- import importlib
53import logging
64import types
75from functools import cached_property
@@ -24,12 +22,13 @@ class ExceptionLogger(ExceptionHandler):
2422 def __init__ (self , logger = None ):
2523 self .logger = logger or LOG
2624
27- # Moto may not be available in stripped-down versions of LocalStack, like LocalStack S3 image.
28- self ._moto_service_exception = types .EllipsisType
29- with contextlib .suppress (ModuleNotFoundError , AttributeError ):
30- self ._moto_service_exception = importlib .import_module (
31- "moto.core.exceptions"
32- ).ServiceException
25+ try :
26+ import moto .core .exceptions
27+
28+ self ._moto_service_exception = moto .core .exceptions .ServiceException
29+ except (ModuleNotFoundError , AttributeError ):
30+ # Moto may not be available in stripped-down versions of LocalStack, like LocalStack S3 image.
31+ self ._moto_service_exception = types .EllipsisType
3332
3433 def __call__ (
3534 self ,
Original file line number Diff line number Diff line change 11"""A set of common handlers to parse and route AWS service requests."""
22
3- import importlib
43import logging
54import traceback
65import types
@@ -158,14 +157,14 @@ class ServiceExceptionSerializer(ExceptionHandler):
158157 def __init__ (self ):
159158 self .handle_internal_failures = True
160159
161- # Moto may not be available in stripped-down versions of LocalStack, like LocalStack S3 image.
162- self ._moto_service_exception = types .EllipsisType
163160 try :
164- self . _moto_service_exception = importlib . import_module (
165- "moto.core.exceptions"
166- ) .ServiceException
161+ import moto . core . exceptions
162+
163+ self . _moto_service_exception = moto . core . exceptions .ServiceException
167164 except (ModuleNotFoundError , AttributeError ) as exc :
165+ # Moto may not be available in stripped-down versions of LocalStack, like LocalStack S3 image.
168166 LOG .debug ("Unable to set up Moto ServiceException translation: %s" , exc )
167+ self ._moto_service_exception = types .EllipsisType
169168
170169 def __call__ (
171170 self ,
You can’t perform that action at this time.
0 commit comments