How to use _call_exception_handlers method in localstack

Best Python code snippet using localstack_python

chain.py

Source:chain.py Github

copy

Full Screen

...49 self.error = e50 if self.stop_on_error:51 self.stopped = True52 # call exception handlers safely53 self._call_exception_handlers(e, response)54 # decide next step55 if self.error:56 raise self.error57 if self.terminated:58 return59 if self.stopped:60 break61 # call response filters62 self._call_response_handlers(response)63 def respond(self, status_code: int = 200, payload: Any = None):64 """65 Convenience method for handlers to stop the chain and set the given status and payload to the current response66 object.67 :param status_code: the HTTP status code68 :param payload: the payload of the response69 """70 self.response.status_code = status_code71 if isinstance(payload, (list, dict)):72 self.response.set_json(payload)73 elif isinstance(payload, (str, bytes, bytearray)):74 self.response.data = payload75 elif payload is None and not self.response.response:76 self.response.response = []77 else:78 self.response.response = payload79 self.stop()80 def stop(self) -> None:81 """82 Stop the processing of the request handlers and proceed with response handlers.83 """84 self.stopped = True85 def terminate(self) -> None:86 """87 Terminate the handler chain, which skips response handlers.88 """89 self.terminated = True90 def throw(self, error: Exception) -> None:91 """92 Raises the given exception after the current request handler is done. This has no effect in response handlers.93 :param error: the exception to raise94 """95 self.error = error96 def _call_response_handlers(self, response):97 for handler in self.response_handlers:98 if self.terminated:99 return100 try:101 handler(self, self.context, response)102 except Exception as e:103 msg = "exception while running response handler"104 if LOG.isEnabledFor(logging.DEBUG):105 LOG.exception(msg)106 else:107 LOG.warning(msg + ": %s", e)108 def _call_exception_handlers(self, e, response):109 for exception_handler in self.exception_handlers:110 try:111 exception_handler(self, e, self.context, response)112 except Exception as nested:113 # make sure we run all exception handlers114 msg = "exception while running exception handler"115 if LOG.isEnabledFor(logging.DEBUG):116 LOG.exception(msg)117 else:118 LOG.warning(msg + ": %s", nested)119class CompositeHandler(Handler):120 """121 A handler that sequentially invokes a list of Handlers, forming a stripped-down version of a handler chain.122 """...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful