Report this object to the moderators.

        :param reason: The user-supplied reason for reporting a comment
            or submission. Default: None (blank reason)
        :returns: The json response from the server.
435773
def report(self, reason=None):
        
        url = self.reddit_session.config['report']
        data = {'id': self.fullname}
        if reason:
            data['reason'] = reason
        response = self.reddit_session.request_json(url, data=data)
        # Reported objects are automatically hidden as well
        # pylint: disable=W0212
        self.reddit_session.evict(
            [self.reddit_session.config['user'],
             urljoin(self.reddit_session.user._url, 'hidden')])
        # pylint: enable=W0212
        return response
785536
def rest_error(self):
    
    error_json = self.__format_error('errors')
    return json.dumps(error_json, indent=1, sort_keys=True)
1259516
def on_comment_posted(sender, comment, request, **kwargs):
    
    content_object = comment.content_object

    moderator = moderation.get_model_moderator(content_object.__class__)
    if moderator is None or comment.__class__ is not CommentModel:
        # No custom moderator means no email would be sent.
        # This still pass the comment to the default moderator.
        default_moderator.email(comment, content_object, request)
629698
def do_response(self, response_args=None, request=None, **kwargs):
        

        links = [Link(href=h, rel=OIC_ISSUER) for h in kwargs['hrefs']]

        _response = JRD(subject=kwargs['subject'], links=links)

        info = {
            'response': _response.to_json(),
            'http_headers': [('Content-type', 'application/json')]
        }

        return info
709043
def report(self, req_handler):
        ""
        if self.exc:
            req_handler.send_exception(self.code, self.exc, self.headers)
            return

        text = (self.text
                or BaseHTTPRequestHandler.responses[self.code][1]
                or "Unknown error")

        getattr(req_handler, "send_error_%s" % self.ctype, 'send_error_msg')(self.code, text, self.headers)
417255
private void sendRecordFailedNotify(String reason) {
        Status failedStatus = new Status(StatusCodes.NS_RECORD_FAILED);
        failedStatus.setLevel(Status.ERROR);
        failedStatus.setClientid(getStreamId());
        failedStatus.setDetails(getPublishedName());
        failedStatus.setDesciption(reason);

        StatusMessage failedMsg = new StatusMessage();
        failedMsg.setBody(failedStatus);
        pushMessage(failedMsg);
    }
557864
def json_response(func):
    

    @wraps(func)
    def wrapper(request, *args, **kwargs):
        res = func(request, *args, **kwargs)
        request.setHeader('Content-Type', 'application/json')
        return json.dumps(res)

    return wrapper
893229
def get_reason_for_status(status_code):
        

        if status_code in requests.status_codes.codes:
            return requests.status_codes._codes[status_code][0].replace('_',
                                                                        ' ')
        else:
            return 'Unknown status code - {0}'.format(status_code)
1154487
def squit(self, server, reason=''):
        
        with self.lock:
            self.send('SQUIT %s :%s' % (server, reason))

            while self.readable():
                msg = self._recv(expected_replies=('SQUIT',))
                if msg[0] == 'SQUIT':
                    if not self.hide_called_events:
                        self.stepback()
1057438
def checkValid(cls, reason):
        
        if reason not in cls.__VALID_REASONS:
            raise ValueError("reason must be one of {}, got {}".format(cls.__VALID_REASONS, reason))
682720
function handleResponseError(error) {
    console.error('handleResponseError', error)
    let reason
    const status = error.response.status

    if (status === 404) {
        reason = wrap('接口不存在')
    } else {
        reason = wrap(defaultErrorMessage)
    }

    return reason
}
660131
def perform_flag(request, comment):
    
    flag, created = comments.models.CommentFlag.objects.get_or_create(
        comment = comment,
        user    = request.user,
        flag    = comments.models.CommentFlag.SUGGEST_REMOVAL
    )
    signals.comment_was_flagged.send(
        sender  = comment.__class__,
        comment = comment,
        flag    = flag,
        created = created,
        request = request,
    )
1276511
def send_callback_json_message(value, *args, **kwargs):
    

    if value:
        kwargs['result'] = value

    send_json_message(args[0], args[1], **kwargs)

    return value
892422
def _get_error_reason(response):
        
        try:
            body = response.json()
            if body and 'reason' in body:
                return body['reason']
        except ValueError:
            pass
        return response.content
231670
public synchronized void onRequestRejected(String reason) {
		allRequestsTracker.onRequestRejected(reason);
		recentRequestsTracker.onRequestRejected(reason);
		meter.mark();
	}
818209
public synchronized void onRequestFailed(Throwable reason) {
		executing.decrement();
		failed.increment();
		lastFailureReason = (reason == null) ? null : reason.getClass()
				.getName() + ": " + reason.getMessage();
	}
521621
def get_response(wsgi_request):
    '''
        
    '''
    service_start_time = datetime.now()
    # Get the view / handler for this request
    view, args, kwargs = resolve(wsgi_request.path_info)

    kwargs.update({"request": wsgi_request})

    # Let the view do his task.
    try:
        resp = view(*args, **kwargs)
    except Exception as exc:
        resp = HttpResponseServerError(content=exc.message)

    headers = dict(resp._headers.values())
    # Convert HTTP response into simple dict type.
    d_resp = {"status_code": resp.status_code, "reason_phrase": resp.reason_phrase,
              "headers": headers}
    try:
        d_resp.update({"body": resp.content})
    except ContentNotRenderedError:
        resp.render()
        d_resp.update({"body": resp.content})

    # Check if we need to send across the duration header.
    if _settings.ADD_DURATION_HEADER:
        d_resp['headers'].update({_settings.DURATION_HEADER_NAME: (datetime.now() - service_start_time).seconds})

    return d_resp