using in-memory db
This commit is contained in:
1 parent
00c234541d
commit
499752e02f
6 files changed
+51
-115
No files matched your search
+23
-1
@@ -1,3 +1,7 @@
|
||||
import traceback
|
||||
from typing import NamedTuple
|
||||
|
||||
|
||||
class ErrorSet(Exception):
|
||||
"""An exception collection exception"""
|
||||
|
||||
@@ -7,6 +11,24 @@ class ErrorSet(Exception):
|
||||
|
||||
def gen_message(self):
|
||||
if len(self.errors) > 1:
|
||||
return "Encountered multiple errors:\n >" + "\n >".join(map(repr, self.errors))
|
||||
return "Encountered multiple errors:\n >" + "\n >".join(
|
||||
map(FormattedError.from_error, self.errors)
|
||||
)
|
||||
else:
|
||||
return str(self.errors[0].args)
|
||||
|
||||
|
||||
class FormattedError(NamedTuple):
|
||||
error_name: str
|
||||
error_message: str
|
||||
error_traceback: str
|
||||
original_error: Exception
|
||||
|
||||
@classmethod
|
||||
def from_error(cls, err: Exception):
|
||||
return cls(
|
||||
error_name=str(err.__class__.__name__),
|
||||
error_message=str(err.args),
|
||||
error_traceback="\n\n".join(traceback.format_tb(err.__traceback__)),
|
||||
original_error=err,
|
||||
)
|
||||
Reference in new issue
Block a user