def render_exception(error, context=None, request=None, user_locale=None):
 error_message = error.args[0]
 message = oslo_i18n.translate(error_message, desired_locale=user_locale)
 if (message is error_message):
  message = six.text_type(message)
 body = {'error': {'code': error.code, 'title': error.title, 'message': message}}
 headers = []
 if isinstance(error, exception.AuthPluginException):
  body['error']['identity'] = error.authentication
 elif isinstance(error, exception.Unauthorized):
  local_context = {}
  if request:
   local_context = {'environment': request.environ}
  elif (context and ('environment' in context)):
   local_context = {'environment': context['environment']}
  url = Application.base_url(local_context, 'public')
  headers.append(('WWW-Authenticate', ('Keystone uri="%s"' % url)))
 return render_response(status=(error.code, error.title), body=body, headers=headers)

def render_exception ( error , context = None , request = None , user_locale = None ) : error_message = error . args [ 0 ] message = oslo_i18n . translate ( error_message , desired_locale = user_locale ) if ( message is error_message ) : message = six . text_type ( message ) body = { 'error' : { 'code' : error . code , 'title' : error . title , 'message' : message } } headers = [ ] if isinstance ( error , exception . AuthPluginException ) : body [ 'error' ] [ 'identity' ] = error . authentication elif isinstance ( error , exception . Unauthorized ) : local_context = { } if request : local_context = { 'environment' : request . environ } elif ( context and ( 'environment' in context ) ) : local_context = { 'environment' : context [ 'environment' ] } url = Application . base_url ( local_context , 'public' ) headers . append ( ( 'WWW-Authenticate' , ( 'Keystone uri="%s"' % url ) ) ) return render_response ( status = ( error . code , error . title ) , body = body , headers = headers )
forms a wsgi response based on the current error .