Skip to content

Commit

Permalink
Handle command errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kedder committed Aug 18, 2020
1 parent 8f152a9 commit 683cf2a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/ovshell_core/setupapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ def __init__(

def create(self) -> urwid.Widget:
message = urwid.Text(self.description)
return urwid.LineBox(urwid.Pile([message]), title=self.title)
self.contents = urwid.Pile([message])
return urwid.LineBox(self.contents, title=self.title)

def get_modal_opts(self) -> api.ModalOptions:
return api.ModalOptions(
Expand Down Expand Up @@ -338,9 +339,17 @@ async def run(self, command: str, args: List[str]) -> None:
loop.call_soon(self._handle_success)

def _handle_error(self, result: int, errors: str) -> None:
pass
self.screen.pop_activity()
error_msg = urwid.Text([("error message", "Command failed"), "\n\n", errors])
dialog = self.screen.push_dialog(self.title, error_msg)
dialog.add_button("Close", self._run_error_handlers)

def _handle_success(self) -> None:
self.screen.pop_activity()
for h in self._success_handlers:
h()

def _run_error_handlers(self) -> bool:
for h in self._failure_handlers:
h()
return True

0 comments on commit 683cf2a

Please sign in to comment.