From 90b747061c7bf8efe624eeb7842789ac98a45709 Mon Sep 17 00:00:00 2001 From: Jeff Peeler Date: Mon, 19 Nov 2012 12:10:12 -0500 Subject: [PATCH] Provide more information with template URL error Previously a generic read error was given. Inform the user with proper exceptions for: the case when a resource is present but non-responsive and when a resource is present but the requested data could not be found. Fixes bug 1072951 Change-Id: I35b92cea38358691015f8752e80efc6720e34e48 Signed-off-by: Jeff Peeler --- heat/api/cfn/v1/stacks.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/heat/api/cfn/v1/stacks.py b/heat/api/cfn/v1/stacks.py index 0be854ca..552907b6 100644 --- a/heat/api/cfn/v1/stacks.py +++ b/heat/api/cfn/v1/stacks.py @@ -21,6 +21,7 @@ import httplib import json import socket import urlparse +import errno from heat.api.aws import exception from heat.api.aws import utils as api_utils from heat.common import wsgi @@ -231,14 +232,26 @@ class StackController(object): conn = httplib.HTTPSConnection(url.netloc) else: conn = httplib.HTTPConnection(url.netloc) - conn.request("GET", url.path) + + try: + conn.request("GET", url.path) + except Exception as e: + if e.errno == errno.ECONNREFUSED: + msg = _('Connection refused to %s' % url.netloc) + raise exception.HeatInvalidParameterValueError(detail=msg) + raise + r1 = conn.getresponse() logger.info('status %d' % r1.status) - if r1.status == 200: + if r1.status == 200: # OK data = r1.read() conn.close() + elif r1.status == 404: # NOT_FOUND + msg = _('No match found for %s' % req.params['TemplateUrl']) + raise exception.HeatInvalidParameterValueError(detail=msg) else: - data = None + msg = _('Unexpected error, request returned %d' % r1.status) + raise exception.HeatInvalidParameterValueError(detail=msg) return data return None -- 2.45.2