mwhudson / livefs-editor

GNU General Public License v3.0
68 stars 31 forks source link

Interest in human friendly errors? #53

Closed cfroystad closed 1 month ago

cfroystad commented 9 months ago

After I added support for adding specific package versions to pool, this has resulted in a few interesting error messages when a specific package is no longer available (for whichever reason a package is removed from a repository)

Problem The error message is difficult to interpret for a user not intimately familiar with livefs-editor

Example - problem

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.10/dist-packages/livefs_edit/__main__.py", line 100, in <module>
    main(sys.argv[1:])
  File "/usr/local/lib/python3.10/dist-packages/livefs_edit/__main__.py", line 82, in main
    func(ctxt, **kw)
  File "/usr/local/lib/python3.10/dist-packages/livefs_edit/actions.py", line 58, in impl
    return func(ctxt, **kw)
  File "/usr/local/lib/python3.10/dist-packages/livefs_edit/actions.py", line 487, in add_packages_to_pool
    package.candidate = package.versions.get(package_version)
  File "/usr/lib/python3/dist-packages/apt/package.py", line 1086, in candidate
    self._pcache._depcache.set_candidate_ver(self._pkg, version._cand)
AttributeError: 'NoneType' object has no attribute '_cand'

Suggested solution Make a custom error message which provides more helpful output to the user

Example: "Could not satisfy version requirement. Package has no version "

Would this be an addition that could be of interest so that it could be accepted? If so, I'll submit a PR shortly :slightly_smiling_face: Or would you prefer a different approach?