summaryrefslogtreecommitdiff
path: root/glance_store/common
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-09-19 23:53:30 +0000
committerGerrit Code Review <review@openstack.org>2014-09-19 23:53:30 +0000
commit692a6cdc6ec516f3cd5fdc600e20c6cb6fc3ca6d (patch)
tree1e6c18eb7bb6f6a454f01013cf880e57dee1c255 /glance_store/common
parent578299499cc8836f6a2c9d10850928d547055dca (diff)
parent03331b19f327234d7f8f060d0cd361b2e36330c1 (diff)
downloadglance_store-692a6cdc6ec516f3cd5fdc600e20c6cb6fc3ca6d.tar.gz
Merge "Adding common.utils.exception_to_str() to avoid encoding issue"
Diffstat (limited to 'glance_store/common')
-rw-r--r--glance_store/common/config.py3
-rw-r--r--glance_store/common/utils.py15
2 files changed, 17 insertions, 1 deletions
diff --git a/glance_store/common/config.py b/glance_store/common/config.py
index 17e5b42..7ec3824 100644
--- a/glance_store/common/config.py
+++ b/glance_store/common/config.py
@@ -26,6 +26,7 @@ from oslo.config import cfg
from paste import deploy
from glance.version import version_info as version
+from glance_store.common import utils
paste_deploy_opts = [
cfg.StrOpt('flavor',
@@ -213,6 +214,6 @@ def load_paste_app(app_name, flavor=None, conf_file=None):
"configuration file %(conf_file)s."
"\nGot: %(e)r") % {'app_name': app_name,
'conf_file': conf_file,
- 'e': e})
+ 'e': utils.exception_to_str(e)})
logger.error(msg)
raise RuntimeError(msg)
diff --git a/glance_store/common/utils.py b/glance_store/common/utils.py
index fb77519..d240b86 100644
--- a/glance_store/common/utils.py
+++ b/glance_store/common/utils.py
@@ -25,6 +25,9 @@ try:
from eventlet import sleep
except ImportError:
from time import sleep
+import six
+
+from glance_store.openstack.common import strutils
LOG = logging.getLogger(__name__)
@@ -137,3 +140,15 @@ class CooperativeReader(object):
def __iter__(self):
return cooperative_iter(self.fd.__iter__())
+
+
+def exception_to_str(exc):
+ try:
+ error = six.text_type(exc)
+ except UnicodeError:
+ try:
+ error = str(exc)
+ except UnicodeError:
+ error = ("Caught '%(exception)s' exception." %
+ {"exception": exc.__class__.__name__})
+ return strutils.safe_encode(error, errors='ignore')