Skip to content

Commit

Permalink
Gracefully handle pixbuf error instead of crashing #248
Browse files Browse the repository at this point in the history
  • Loading branch information
Cimbali committed Jul 4, 2022
1 parent 3dd3363 commit c76262d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pympress/pointer.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,13 @@ def load_pointer(self, name):
Args:
name (`str`): Name of the pointer to load
"""
if name in ['red', 'green', 'blue']:
self.pointer = GdkPixbuf.Pixbuf.new_from_file(util.get_icon_path('pointer_' + name + '.png'))
else:
if name not in ['red', 'green', 'blue']:
raise ValueError('Wrong color name')
path = util.get_icon_path('pointer_' + name + '.png')
try:
self.pointer = GdkPixbuf.Pixbuf.new_from_file(path)
except Exception:
logger.exception(_('Failed loading pixbuf for pointer "{}" from: {}'.format(name, path)))


def change_pointercolor(self, action, target):
Expand Down

0 comments on commit c76262d

Please sign in to comment.