Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rich's traceback output #586

Closed
mjordan opened this issue Mar 22, 2023 · 0 comments
Closed

Use rich's traceback output #586

mjordan opened this issue Mar 22, 2023 · 0 comments
Assignees
Labels
UX User experience / reduction of potential for user error

Comments

@mjordan
Copy link
Owner

mjordan commented Mar 22, 2023

The rich library (already required by Workbench) provides a way to print exception tracebacks so that they are much more readable. For example, Python's default looks like this:

Traceback (most recent call last):
  File "/home/mark/hacking/islandora_workbench/./workbench", line 1350, in <module>
    check_input(config, args)
  File "/home/mark/hacking/islandora_workbench/workbench_utils.py", line 1137, in check_input
    print("Foo" + none)
NameError: name 'none' is not defined. Did you mean: 'None'?

but rich produces exception tracebacks like this:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/mark/hacking/islandora_workbench/./workbench:1350 in <module>                              │
│                                                                                                  │
│   1347 │   │   │   if config['task'] == 'create_from_files':                                     │
│   1348 │   │   │   │   check_input_for_create_from_files(config, args)                           │
│   1349 │   │   │   else:                                                                         │
│ ❱ 1350 │   │   │   │   check_input(config, args)                                                 │
│   1351 except KeyboardInterrupt:                                                                 │
│   1352 │   print('Exiting before entire --check completed.')                                     │
│   1353 │   logging.warning('Workbench exiting after receiving "ctrl-c" during --check.')         │
│                                                                                                  │
│ /home/mark/hacking/islandora_workbench/workbench_utils.py:1137 in check_input                    │
│                                                                                                  │
│   1134 │   if config['id_field'] not in entity_fields:                                           │
│   1135 │   │   reserved_fields.append(config['id_field'])                                        │
│   1136 │                                                                                         │
│ ❱ 1137 │   print("foo" + None)                                                                   │
│   1138 │                                                                                         │
│   1139 │   # Check the config file.                                                              │
│   1140 │   tasks = [                                                                             │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: can only concatenate str (not "NoneType") to str
@mjordan mjordan added the UX User experience / reduction of potential for user error label Mar 22, 2023
@mjordan mjordan self-assigned this Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UX User experience / reduction of potential for user error
Projects
None yet
Development

No branches or pull requests

1 participant