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

catch pyfiglet.FontNotFound error #92

Open
n1trux opened this issue Oct 25, 2023 · 0 comments
Open

catch pyfiglet.FontNotFound error #92

n1trux opened this issue Oct 25, 2023 · 0 comments

Comments

@n1trux
Copy link

n1trux commented Oct 25, 2023

If you select a figlet font which is not available on your system, you get an ugly error from pyfiglet. This should probably be caught and replaced with a more user friendly error message.

Example:

# termdown 2m -f mono12

Traceback (most recent call last):
  File "/usr/bin/termdown", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/termdown.py", line 800, in main
    curses.wrapper(countdown, **kwargs)
  File "/usr/lib/python3.11/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/termdown.py", line 160, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/termdown.py", line 313, in countdown
    figlet = Figlet(font=font)
             ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyfiglet/__init__.py", line 862, in __init__
    self.setFont()
  File "/usr/lib/python3.11/site-packages/pyfiglet/__init__.py", line 869, in setFont
    self.Font = FigletFont(font=self.font)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyfiglet/__init__.py", line 128, in __init__
    self.data = self.preloadFont(font)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyfiglet/__init__.py", line 168, in preloadFont
    raise FontNotFound(font)
pyfiglet.FontNotFound: mono12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant