Skip to content

Commit

Permalink
making process_response more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Greenberg committed Jan 28, 2020
1 parent 716f11d commit 5e105ce
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion multivitamin/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .apis import CommAPI
from .module import Module
from .data import Response, Request
from .module.codes import Codes


HEALTHPORT = os.environ.get("PORT", 5000)
Expand Down Expand Up @@ -152,7 +153,15 @@ def _process_request(self, request):

for module in self.modules:
log.info(f"Processing {request} in module: {module}")
response = module.process(response)
try:
response = module.process(response)
except Exception as e:
log.error(traceback.format_exc())
log.error(f"Processing {request} in {module} FAILED. "
f"Setting error code to {Codes.ERROR_PROCESSING}.")
module.code = Codes.ERROR_PROCESSING
response = module.update_and_return_response()

log.info(f"Processing {request} in module: {module}"
f" ...Status: {module.code}")
if response is not None:
Expand Down

0 comments on commit 5e105ce

Please sign in to comment.