Skip to content

Commit

Permalink
handle traceback better and fix broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Jul 4, 2024
1 parent ed7512f commit 346e596
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/model/model.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import traceback
from typing import Union, List, Dict, Any
from abc import ABC, abstractmethod
import os
Expand Down Expand Up @@ -46,7 +47,10 @@ def handle_fingerprinting_error(self, e):
error_context = {"error": str(e)}
for attr in ["__cause__", "__context__", "args", "__traceback__"]:
if attr in dir(e):
error_context[attr] = getattr(e, attr)
if attr == "__traceback__":
error_context[attr] = '\n'.join(traceback.format_tb(getattr(e, attr)))
else:
error_context[attr] = getattr(e, attr)
capture_custom_message("Error during fingerprinting for {self.model_name}", 'info', error_context)
return schemas.ErrorResponse(error=str(e), error_details=error_context)

Expand Down
4 changes: 2 additions & 2 deletions test/lib/queue/test_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ def test_error_capturing_in_get_response(self, mock_cache_set, mock_cache_get):

self.assertIsInstance(result, schemas.ErrorResponse)
self.assertEqual(result.error, "Test error")
self.assertIn("exception", result.error_details)
self.assertEqual(result.error_details["exception"], "Test error")
self.assertIn("error", result.error_details)
self.assertEqual(result.error_details["error"], "Test error")

if __name__ == '__main__':
unittest.main()

0 comments on commit 346e596

Please sign in to comment.