From 65f1bf52be1537cd4b077e0665cb76c462bb013b Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Tue, 20 Oct 2015 21:51:54 +0300 Subject: Give nicer error for invalid environment --- gsxws/core.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gsxws/core.py b/gsxws/core.py index 083efed..17f6556 100644 --- a/gsxws/core.py +++ b/gsxws/core.py @@ -278,7 +278,11 @@ class GsxRequest(object): "Send the final SOAP message" global GSX_ENV, GSX_REGION, GSX_HOSTS, GSX_URL, GSX_TIMEOUT - self._url = GSX_URL.format(env=GSX_HOSTS[GSX_ENV], region=GSX_REGION) + try: + self._url = GSX_URL.format(env=GSX_HOSTS[GSX_ENV], region=GSX_REGION) + except KeyError: + raise GsxError('GSX environment (%s) must be one of: %s' % (GSX_ENV, + ', '.join(GSX_HOSTS.keys()))) logging.debug(self._url) logging.debug(xmldata) -- cgit v1.2.3