99import os
1010import time
1111
12- from datadog_lambda .tracing import emit_telemetry_on_exception_outside_of_handler
13- from datadog_lambda .wrapper import datadog_lambda_wrapper
12+ from datadog_lambda .wrapper import datadog_lambda_wrapper , error_fallback_handler
1413from datadog_lambda .module_name import modify_module_name
1514
1615
1716class HandlerError (Exception ):
1817 pass
1918
2019
21- class _ErrorFallbackHandler (object ):
22- """
23- Decorator for when an exception occurs outside of the handler function.
24- Emits telemetry and re-raises the exception.
25- """
26-
27- def __init__ (self , exception , modified_mod_name , start_time_ns ):
28- self .exception = exception
29- self .modified_mod_name = modified_mod_name
30- self .start_time_ns = start_time_ns
31-
32- def __call__ (self , event , context , ** kwargs ):
33- emit_telemetry_on_exception_outside_of_handler (
34- context ,
35- self .exception ,
36- self .modified_mod_name ,
37- self .start_time_ns ,
38- )
39- raise self .exception
40-
41-
4220path = os .environ .get ("DD_LAMBDA_HANDLER" , None )
4321if path is None :
4422 raise HandlerError (
@@ -58,4 +36,4 @@ def __call__(self, event, context, **kwargs):
5836 handler_func = getattr (handler_module , handler_name )
5937 handler = datadog_lambda_wrapper (handler_func )
6038except Exception as e :
61- handler = _ErrorFallbackHandler (e , modified_mod_name , start_time_ns )
39+ handler = error_fallback_handler (e , modified_mod_name , start_time_ns )
0 commit comments