parameters: (self, status_code, **kwargs)
docstring: APIHandler errors are JSON, not human pages
docstring_summary: APIHandler errors are JSON, not human pages
docstring_tokens: APIHandler errors are JSON not human pages
function: def write_error(self, status_code, **kwargs):
          """APIHandler errors are JSON, not human pages"""
          self.set_header('Content-Type', 'application/json')
          message = responses.get(status_code, 'Unknown HTTP Error')
          reply = {
              'message': message,
          }
          exc_info = kwargs.get('exc_info')
          if exc_info:
              e = exc_info[1]
              if isinstance(e, HTTPError):
                  reply['message'] = e.log_message or message
                  reply['reason'] = e.reason
              else:
                  reply['message'] = 'Unhandled error'
                  reply['reason'] = None
                  reply['traceback'] = ''.join(traceback.format_exception(*exc_info))
          self.log.warning(reply['message'])
          self.finish(json.dumps(reply))
function_tokens: def write_error ( self , status_code , * * kwargs ) : self . set_header ( 'Content-Type' , 'application/json' ) message = responses . get ( status_code , 'Unknown HTTP Error' ) reply = { 'message' : message , } exc_info = kwargs . get ( 'exc_info' ) if exc_info : e = exc_info [ 1 ] if isinstance ( e , HTTPError ) : reply [ 'message' ] = e . log_message or message reply [ 'reason' ] = e . reason else : reply [ 'message' ] = 'Unhandled error' reply [ 'reason' ] = None reply [ 'traceback' ] = '' . join ( traceback . format_exception ( * exc_info ) ) self . log . warning ( reply [ 'message' ] ) self . finish ( json . dumps ( reply ) )