Skip to content

Commit bb91a4b

Browse files
committed
Update:
- Furnish the way returns the error.
1 parent ee208c3 commit bb91a4b

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

app/libs/base_handler.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async def handle(self, context: Context):
2020
except Exception as e:
2121
_exception_handler: "Handler" = ExceptionHandler()
2222
# Extract the stack trace and log the exception
23-
return await _exception_handler.handle(context, e)
23+
return await _exception_handler.handle(self._next_handler, context, e)
2424

2525

2626
class DefaultCompletionHandler(Handler):
@@ -51,11 +51,11 @@ async def handle(self, context: Context):
5151

5252

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

app/libs/tools_handler.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ async def handle(self, context: Context):
228228
return JSONResponse(content=context.response, status_code=200)
229229
except Exception as e:
230230
# Log the exception or handle it as needed
231-
print(e)
232-
context.response = {
233-
"error": "An error occurred processing the tool response"
234-
}
235-
return JSONResponse(content=context.response, status_code=500)
231+
# context.response = {
232+
# "error": "An error occurred processing the tool response"
233+
# }
234+
# return JSONResponse(content=context.response, status_code=500)
235+
raise e
236236

237237
return await super().handle(context)

0 commit comments

Comments
 (0)