In Python, I’m persisting some errors to a database.
I want to be able to group these errors by their error details.
However, currently, I am persisting the exception itself as follows:
try:
//logic
except Exception as e:
persist(e) //this just does an insert of e
This is resulting in a DB table like this:
+------------------+---------------------------------------+
| name | failure_reason |
+------------------+---------------------------------------+
| name1 | 001003 (42000): 01b51169-0409-e03e-0075-e9028c3cc103: SQL compilation error:
syntax error line 1 at position 0 unexpected 'seelect'. |
| name1 | 001003 (42000): 01b5116c-0409-e03e-0075-e9028c3cf86b: SQL compilation error:
syntax error line 1 at position 0 unexpected 'seelect'. |
| name2 | 001003 (42000): 02b6117h-9876-e03f-0075-e9028c2ayhwb: SQL compilation error:
syntax error line 1 at position 0 unexpected 'seelect'. |
+------------------+---------------------+-----------------+
As you can see, when I persist the Exception itself, it contains a UUID which stops me from easily grouping on the error.
I’ve tried using the following, but what I want is something that will give me just SQL compilation error: syntax error line 1 at position 0 unexpected 'seelect'.
e.__class__.__name__
str(e)
repr(e)
traceback.format_exc()
– this includes the UUID too