Skip to content

Commit 6fab360

Browse files
committed
Fixed #68 -- better CLI handling of EnvironmentErrors.
1 parent 06c4347 commit 6fab360

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

client/deis.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,11 @@ def _dispatch(self, method, path, body=None,
236236
Dispatch an API request to the active Deis controller
237237
"""
238238
func = getattr(self._session, method.lower())
239-
url = urlparse.urljoin(self._settings['controller'], path, **kwargs)
239+
controller = self._settings['controller']
240+
if not controller:
241+
raise EnvironmentError(
242+
'No active controller. Use `deis login` or `deis register` to get started.')
243+
url = urlparse.urljoin(controller, path, **kwargs)
240244
response = func(url, data=body, headers=headers)
241245
return response
242246

@@ -646,7 +650,7 @@ def formations_create(self, args):
646650
try:
647651
self._session.git_root() # check for a git repository
648652
except EnvironmentError:
649-
print 'No git repository found, use `git init` to create one'
653+
print 'No git repository found, use `git init` to create one.'
650654
return
651655
for opt in ('--id',):
652656
o = args.get(opt)
@@ -1345,9 +1349,8 @@ def main():
13451349
# dispatch the CLI command
13461350
try:
13471351
method(args)
1348-
except EnvironmentError:
1349-
print 'Could not find git remote for deis'
1350-
raise DocoptExit()
1352+
except EnvironmentError as err:
1353+
raise DocoptExit(err.message)
13511354

13521355

13531356
if __name__ == '__main__':

0 commit comments

Comments
 (0)