Skip to content

Commit

Permalink
Issue #6: Handle exceptions gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaeon committed Apr 15, 2015
1 parent dce1fb1 commit d68995d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/pvc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"""

import pyVmomi

import requests
requests.packages.urllib3.disable_warnings()

Expand Down Expand Up @@ -129,9 +131,14 @@ def login(self):
self.dialog.set_background_title(background_title)
return True
except Exception as e:
if isinstance(e, pyVmomi.vim.MethodFault):
msg = e.msg
else:
msg = e

self.dialog.msgbox(
title='Login failed',
text='Failed to login to {}\n\n{}\n'.format(self.agent.host, e.msg)
text='Failed to login to {}\n\n{}\n'.format(self.agent.host, msg)
)

def run(self):
Expand Down

0 comments on commit d68995d

Please sign in to comment.