Skip to content

Commit

Permalink
Merge pull request #22 from unclecode/main
Browse files Browse the repository at this point in the history
Auto PR from main to live
  • Loading branch information
github-actions[bot] authored Mar 19, 2024
2 parents fe80602 + bb91a4b commit 3b3b8b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions app/libs/base_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async def handle(self, context: Context):
except Exception as e:
_exception_handler: "Handler" = ExceptionHandler()
# Extract the stack trace and log the exception
return await _exception_handler.handle(context, e)
return await _exception_handler.handle(self._next_handler, context, e)


class DefaultCompletionHandler(Handler):
Expand Down Expand Up @@ -51,11 +51,11 @@ async def handle(self, context: Context):


class ExceptionHandler(Handler):
async def handle(self, context: Context, exception: Exception):
print(f"Error processing the request: {exception}")
print(traceback.format_exc())
async def handle(self, handler: Handler, context: Context, exception: Exception):
print(f"Error processing the request: {str(handler.__class__) } - {exception}")
# print(traceback.format_exc())
return JSONResponse(
content={"error": "An unexpected error occurred. " + str(exception)},
content={"error": "An unexpected error occurred, within handler " + str(handler.__class__) + " : " + str(exception)},
status_code=500,
)

Expand Down
10 changes: 5 additions & 5 deletions app/libs/tools_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ async def handle(self, context: Context):
return JSONResponse(content=context.response, status_code=200)
except Exception as e:
# Log the exception or handle it as needed
print(e)
context.response = {
"error": "An error occurred processing the tool response"
}
return JSONResponse(content=context.response, status_code=500)
# context.response = {
# "error": "An error occurred processing the tool response"
# }
# return JSONResponse(content=context.response, status_code=500)
raise e

return await super().handle(context)

0 comments on commit 3b3b8b6

Please sign in to comment.