'Write JSON errors instead of HTML'

def write_error(self, status_code, **kwargs):

    exc_info = kwargs.get('exc_info')
    message = ''
    status_message = responses.get(status_code, 'Unknown    Error')
    if exc_info:
        exception = exc_info[1]
        try:
            message = (exception.log_message % exception.args)
        except Exception:
            pass
        reason = getattr(exception, 'reason', '')
        if reason:
            status_message = reason
    self.write(json.dumps({'status': status_code, 'message': (message or status_message)}))
