-
Notifications
You must be signed in to change notification settings - Fork 0
Description
I found that the traceback in the error message is rather long. Do you think it is useful too see all that contexts or would it be more beneficial to make the output shorter so it is easier to read?
For example, take this snippet from the docs:
resource_properties = sp.ResourceProperties(
name="Woolly Dormice (2015, Toros Dağları)",
)
sp.check_resource_properties(resource_properties)The error message is rather verbose:
+ Exception Group Traceback (most recent call last):
| File "/home/runner/work/seedcase-sprout/seedcase-sprout/.venv/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3699, in run_code
| exec(code_obj, self.user_global_ns, self.user_ns)
| File "/tmp/ipykernel_3735/776683067.py", line 4, in <module>
| sp.check_resource_properties(resource_properties)
| File "/home/runner/work/seedcase-sprout/seedcase-sprout/src/seedcase_sprout/check_properties.py", line 113, in check_resource_properties
| raise error_info
| File "/home/runner/work/seedcase-sprout/seedcase-sprout/src/seedcase_sprout/check_properties.py", line 104, in check_resource_properties
| _generic_check_properties(
| File "/home/runner/work/seedcase-sprout/seedcase-sprout/src/seedcase_sprout/check_properties.py", line 171, in _generic_check_properties
| raise ExceptionGroup(
| ExceptionGroup: The following checks failed on the properties:
| PackageProperties(name=None, id=None, title=None, description=None, homepage=None, version=None, created=None, contributors=None, keywords=None, image=None, licenses=None, resources=[ResourceProperties(name='Woolly Dormice (2015, Toros Dağları)', path=None, type=None, title=None, description=None, sources=None, licenses=None, format=None, mediatype=None, encoding=None, bytes=None, hash=None, schema=None)], sources=None) (4 sub-exceptions)
+-+---------------- 1 ----------------
| seedcase_sprout.check_datapackage.check_error.CheckError: Error at `$.description` caused by `required`: 'description' is a required property
+---------------- 2 ----------------
| seedcase_sprout.check_datapackage.check_error.CheckError: Error at `$.name` caused by `pattern`: 'Woolly Dormice (2015, Toros Dağları)' does not match '^[a-z0-9._-]+$'
+---------------- 3 ----------------
| seedcase_sprout.check_datapackage.check_error.CheckError: Error at `$.path` caused by `required`: 'path' is a required property
+---------------- 4 ----------------
| seedcase_sprout.check_datapackage.check_error.CheckError: Error at `$.title` caused by `required`: 'title' is a required property
+------------------------------------
I actually think Github's formatting of the block above with infinite horizontal scrolling makes it appear more aesthetically pleasing than what it is. In a terminal window 1/3 of the screen (which seems like a common enough scenario), you get softwrapping and end up with something like this which become harder to parse:
From a readability perspective, something like this is less overwhelming and easier to grasp while still containing all the information to act upon (ie understanding what is wrong and where):
Found 4 issues with the specification in ResourceProperties:
+-+---------------- 1 ----------------
| seedcase_sprout.check_datapackage.check_error.CheckError: Error at `$.description` caused by `required`: 'description' is a required property
+---------------- 2 ----------------
| seedcase_sprout.check_datapackage.check_error.CheckError: Error at `$.name` caused by `pattern`: 'Woolly Dormice (2015, Toros Dağları)' does not match '^[a-z0-9._-]+$'
+---------------- 3 ----------------
| seedcase_sprout.check_datapackage.check_error.CheckError: Error at `$.path` caused by `required`: 'path' is a required property
+---------------- 4 ----------------
| seedcase_sprout.check_datapackage.check_error.CheckError: Error at `$.title` caused by `required`: 'title' is a required property
+------------------------------------
Truncating each messages and reformatting the output could help further (if possible):
CheckError: Found 4 issues with the specification in ResourceProperties:
1. Error at `$.description` caused by `required`: 'description' is
a required property
2. Error at `$.name` caused by `pattern`: 'Woolly Dormice (2015, Toros
Dağları)' does not match '^[a-z0-9._-]+$'
3. Error at `$.path` caused by `required`: 'path' is a required property
4. Error at `$.title` caused by `required`: 'title' is a required property
Or even:
CheckError: Found 4 issues with the specification in ResourceProperties:
1. 'description' is a required property
2. 'path' is a required property
3. 'title' is a required property
4. 'Woolly Dormice (2015, Toros Dağları)' does not match '^[a-z0-9._-]+$'
Potentially the first three could be combined into a single line, but I'll stop here for this issue.
Related to #14 and #11 (especially the last suggestion above), but it didn't seem to fully fit either as they are discussing different aspect of the error message formatting.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status