Send a 500 error response
768211
function error500(req, res, errorText, detail, templateDir, consoleLogFile, appSpec) {
  fsutil.safeTail_p(consoleLogFile, 8192)
  .fail(function(consoleLog) {
    return;
  })
  .then(function(consoleLog) {
    render.sendPage(res, 500, 'An error has occurred', {
      template: 'error-500',
      templateDir: templateDir,
      vars: {
        message: errorText,
        detail: detail,
        console: (appSpec && appSpec.settings.appDefaults.sanitizeErrors) ? null : consoleLog
      }
    });
  })
  .fail(function(err) {
    logger.error('Failed to render error 500 page: ' + err.message);
  })
  .fin(function() {
    try {
      res.end();
    } catch(err) {
      logger.error('Error while cleaning up response: ' + err);
    }
  })
  .done();
}
931447
def handler500(request, template_name='500.html'):
    
    t = loader.get_template(template_name) # You need to create a 500.html template.
    return http.HttpResponseServerError(t.render(Context({
        'MEDIA_URL': settings.MEDIA_URL,
        'STATIC_URL': settings.STATIC_URL
    })))
828842
def server_error(request, template_name='500.html'):
    

    response = render_in_page(request, template_name)

    if response:
        return response

    try:
        template = loader.get_template(template_name)
    except TemplateDoesNotExist:
        return http.HttpResponseServerError('<h1>Server Error (500)</h1>', content_type='text/html')
    return http.HttpResponseServerError(template.render(Context({})))
1066051
function sendError(error, params) {
    checkParams(params);
    
    params.status = FILE_NOT_FOUND;
    
    const data = error.message || String(error);
    
    logError(error.stack);
    
    send(data, params);
}
808835
def assert_200(response, max_len=500):
  
  if response.status_code == 200:
    return

  raise ValueError(
      "Response was {}, not 200:\n{}\n{}".format(
          response.status_code,
          json.dumps(dict(response.headers), indent=2),
          response.content[:max_len]))
271477
def _raise_for_status(response):
    
    message = ''
    if 400 <= response.status < 500:
        message = '%s Client Error: %s' % (response.status, response.reason)
    elif 500 <= response.status < 600:
        message = '%s Server Error: %s' % (response.status, response.reason)
    else:
        return
    if response.status == 503:
        raise ConnectionError(message)
    if response.headers.get("content-type", "").startswith("application/json"):
        data = json.loads(response.data.decode('utf-8'))
        error = data.get('error', {})
        error_trace = data.get('error_trace', None)
        if "results" in data:
            errors = [res["error_message"] for res in data["results"]
                      if res.get("error_message")]
            if errors:
                raise ProgrammingError("\n".join(errors))
        if isinstance(error, dict):
            raise ProgrammingError(error.get('message', ''),
                                   error_trace=error_trace)
        raise ProgrammingError(error, error_trace=error_trace)
    raise ProgrammingError(message)
1289947
def send_error_msgtxt(self, code, message, headers=None):
        ""
        if headers is None:
            headers = {}

        if isinstance(message, (list, tuple)):
            message = ''.join(message)
        elif isinstance(message, dict):
            message = repr(message)

        self.send_error_explain(code,
                                ''.join(("<pre>\n", cgi.escape(message), "</pre>\n")),
                                headers,
                                "text/html")
403030
def _raise_for_status(response):
    

    http_error_msg = ''

    if 400 <= response.status_code < 500:
        http_error_msg = '%s Client Error: %s for url: %s' % (
            response.status_code, response.reason, response.url)

    elif 500 <= response.status_code < 600:
        http_error_msg = '%s Server Error: %s for url: %s' % (
            response.status_code, response.reason, response.url)

    if http_error_msg:
        spacetrack_error_msg = None

        try:
            json = response.json()
            if isinstance(json, Mapping):
                spacetrack_error_msg = json['error']
        except (ValueError, KeyError):
            pass

        if not spacetrack_error_msg:
            spacetrack_error_msg = response.text

        if spacetrack_error_msg:
            http_error_msg += '\nSpace-Track response:\n' + spacetrack_error_msg

        raise requests.HTTPError(http_error_msg, response=response)
349980
function notFoundError(response, error) {
  var content = errorContentExt(ErrorType.invalidRequest, error);
  send(response, content, StatusCode.notFound);
}
1263217
function ErrorSave (message) {

  Error.call(this);

  // Add Information
  this.name    = 'ErrorSave';
  this.type    = 'server';
  this.status  = 500;
  if (message) {
    this.message = message;
  }

}
396786
def server_error(request, template_name='500.html'):
    
    t = loader.get_template(template_name)
    return HttpResponseServerError(
        t.render(Context({'STATIC_URL': settings.STATIC_URL})))
533866
function sendErrorResponse(err, callback = undefined, returnData = undefined) {
  let error;
  if (err instanceof Error) {
    error = err;
  } else {
    error = new Error(err);
  }

  if (callback) {
    callback(error, returnData);
  } else {
    throw error;
  }
}
1003565
def error(self, code=500):
        
        def wrapper(handler):
            self.error_handler[int(code)] = handler
            return handler
        return wrapper
1058227
def _request_cb(self, env, start_response):
        
        if env['REQUEST_METHOD'] == 'GET':
            return self._handle_GET(env, start_response)

        if env['REQUEST_METHOD'] == 'POST':
            return self._handle_POST(env, start_response)
            
        start_response("500 ERROR", [('Content-Type','text/plain')])
        s = StringIO()
        h = env.items(); h.sort()
        for k,v in h:
            print >>s, k,'=',`v`
        return [s.getvalue()]
776345
def errorhandle(self, resp):            
        """"""
        if self.format == 'json':
            parsed = xmltodict.parse(resp)
            errors = parsed[self.RESPONSE_TOKEN][self.ERROR_TOKEN]
            # Create list of errors if more than one error response is given
            if type(errors) is list and len(errors) > 1:
                messages = ", ".join([" ".join(["{}: {}".format(k,v) for k, v in e.items()]) for e in errors])
            else:
                overlimit = any('transaction limit' in msg.lower() for msg in errors.values())
                if overlimit:
                    raise APILimitExceeded("This API key has used up its daily quota of calls.")
                else:    
                    messages = " ".join(["{}: {}".format(k,v) for k, v in errors.items()])    
        elif self.format == 'xml':
            import xml.etree.ElementTree as ET
            errors = ET.fromstring(resp).findall(self.ERROR_TOKEN)
            messages = ", ".join(err.find('msg').text for err in errors)
        else:
            raise ValueError("Invalid API response format specified: {}." % self.format)        
        
        raise BustimeError("API returned: {}".format(messages))
125450
function(err, req, res, next) {
    if (err) {
        var url = req.url || '';

        log.debug(req.method, req.headers);
        log.error(('Requested url: ' + url).red, ('Error: ' + err.stack).red);

        if (req.xhr) {
            res.status(500).json({msg: 'Server error'});
        } else {
            res.status(500).send('Server error');
        }
    } else {
        next();
    }
}
1082291
public function sendError($message, $code=500) {
        $this->_error = true;
        $statusHeader= "HTTP/1.1 ".$code." ".$message;
        header($statusHeader);
    }