From 117028c3337b69f51cc09de2148c7206ee1b96e1 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 13 Jan 2010 21:48:46 +0100 Subject: Added error handlers for failed commands --- ranger/gui/ui.py | 5 ++++- ranger/gui/widgets/console.py | 10 ++++++++-- ranger/gui/widgets/pager.py | 5 ++++- ranger/gui/widgets/taskview.py | 5 ++++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 771f0b2a..c7c4a14b 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -138,7 +138,10 @@ class UI(DisplayableContainer): if hasattr(self, 'hint'): self.hint(cmd.text) elif hasattr(cmd, 'execute'): - cmd.execute_wrap(self) + try: + cmd.execute_wrap(self) + except Exception as error: + self.fm.notify(error) self.env.key_clear() def get_next_key(self): diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py index 90192bee..6cf00b14 100644 --- a/ranger/gui/widgets/console.py +++ b/ranger/gui/widgets/console.py @@ -123,7 +123,10 @@ class Console(Widget): if cmd == self.commandlist.dummy_object: return - cmd.execute_wrap(self) + try: + cmd.execute_wrap(self) + except Exception as error: + self.fm.notify(error) self.env.key_clear() def type_key(self, key): @@ -265,7 +268,10 @@ class CommandConsole(ConsoleWithTab): cmd = self._get_cmd() if cmd: - cmd.execute() + try: + cmd.execute() + except Exception as error: + self.fm.notify(error) Console.execute(self) diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index c14e0efb..52de9ccf 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -170,7 +170,10 @@ class Pager(Widget): self.env.key_clear() else: if hasattr(cmd, 'execute'): - cmd.execute_wrap(self) + try: + cmd.execute_wrap(self) + except Exception as error: + self.fm.notify(error) self.env.key_clear() def set_source(self, source, strip=False): diff --git a/ranger/gui/widgets/taskview.py b/ranger/gui/widgets/taskview.py index 909577d8..a99a567e 100644 --- a/ranger/gui/widgets/taskview.py +++ b/ranger/gui/widgets/taskview.py @@ -102,7 +102,10 @@ class TaskView(Widget, Accumulator): self.env.key_clear() else: if hasattr(cmd, 'execute'): - cmd.execute_wrap(self) + try: + cmd.execute_wrap(self) + except Exception as error: + self.fm.notify(error) self.env.key_clear() def get_list(self): -- cgit 1.4.1-2-gfad0