#NEWLINE# def build_error( self , err ) : #NEWLINE# #INDENT# '\n        When an exception is encountered, this generates a JSON error message\n        for display to the user.\n\n        :param err: The exception seen. The message is exposed to the user, so\n            beware of sensitive data leaking.\n        :type err: Exception\n\n        :returns: A response object\n        ' #NEWLINE# data = { #NEWLINE# #INDENT# 'error' : six . text_type ( err ) , #NEWLINE# #UNINDENT# } #NEWLINE# if self . is_debug ( ) : #NEWLINE# #INDENT# data [ 'traceback' ] = format_traceback ( sys . exc_info ( ) ) #NEWLINE# #UNINDENT# body = self . serializer . serialize ( data ) #NEWLINE# status = getattr ( err , 'status' , 500 ) #NEWLINE# return self . build_response ( body , status = status )