check for error response
439125
function CheckVoiceSmsError(body,callback)
{

switch(body)
{
case 'code: 104':
callback('Missing Username.');
break;
case 'code: 105':
callback('Missing Password');
break;
case 'code: 201':
callback('Invalid Username Or Password');
break;
case 'code: 601':
callback('Sender ID must be numeric');
break;
case 'code: 602':
callback('Your Current Route is disabled,Kindly Select another Route');
break;
case 'code: 603':
callback('This Sender ID is blacklisted, Please Use a different Sender ID.');
break;
case 'code: 604':
callback('Please Enter Atleast One Correct Number To Send SMS');
break;
case 'code: 606':
callback('Scheduled Date Cannot Be More than Three Weeks');
break;
case 'code: 607':
callback('Please Enter Campaign Name');
break;
case 'code: 608':
callback('Scheduled SMS Cannot Be Less Than Current Time');
break;
case 'code: 609':
callback('End Time Cannot Be Less Than Or Equal To Schedule Time');
break;
case 'code: 610':
callback('Duration can not be set to be zero');
break;
case 'code: 614':
callback('No voice file found Please enter voice file and proceed');
break;
case 'code: 615':
callback('Invalid file Type,Allow Extension are wav,wave,mp3,wma,ra,m4a,arm');
break;
case 'code: 001':
callback('Unable To Connect Database');
break;
case 'code: 002':
callback('Unable To Select Database');
break;
default:
callback(body);
}

}
307596
def return_error_or_body(response)
      if response.status / 100 == 2
        response.body
      else
        raise Checkdin::APIError.new(response.status, response.body)
      end
    end
760696
def error_response(message, status=400, code=None):
    """""""
    from django.http import JsonResponse
    data = {'message': message}
    if code:
        data['code'] = code
    LOG.error("Error response, status code is : {} | {}".format(status, data))
    return JsonResponse(data=data, status=status)
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;
  }
}
225088
def check_error_cmd(result):
    
    return (result.value >= ReturnCode.ERRCMD) and (result.value < ReturnCode.WARNING)
827137
def _check_command_response(response, msg=None, allowable_errors=None,
                            parse_write_concern_error=False):
    
    if "ok" not in response:
        # Server didn't recognize our message as a command.
        raise OperationFailure(response.get("$err"),
                               response.get("code"),
                               response)

    # TODO: remove, this is moving to _check_gle_response
    if response.get("wtimeout", False):
        # MongoDB versions before 1.8.0 return the error message in an "errmsg"
        # field. If "errmsg" exists "err" will also exist set to None, so we
        # have to check for "errmsg" first.
        raise WTimeoutError(response.get("errmsg", response.get("err")),
                            response.get("code"),
                            response)

    if parse_write_concern_error and 'writeConcernError' in response:
        wce = response['writeConcernError']
        raise WriteConcernError(wce['errmsg'], wce['code'], wce)

    if not response["ok"]:

        details = response
        # Mongos returns the error details in a 'raw' object
        # for some errors.
        if "raw" in response:
            for shard in itervalues(response["raw"]):
                # Grab the first non-empty raw error from a shard.
                if shard.get("errmsg") and not shard.get("ok"):
                    details = shard
                    break

        errmsg = details["errmsg"]
        if allowable_errors is None or errmsg not in allowable_errors:

            # Server is "not master" or "recovering"
            if (errmsg.startswith("not master")
                    or errmsg.startswith("node is recovering")):
                raise NotMasterError(errmsg, response)

            # Server assertion failures
            if errmsg == "db assertion failure":
                errmsg = ("db assertion failure, assertion: '%s'" %
                          details.get("assertion", ""))
                raise OperationFailure(errmsg,
                                       details.get("assertionCode"),
                                       response)

            # Other errors
            code = details.get("code")
            # findAndModify with upsert can raise duplicate key error
            if code in (11000, 11001, 12582):
                raise DuplicateKeyError(errmsg, code, response)
            elif code == 50:
                raise ExecutionTimeout(errmsg, code, response)
            elif code == 43:
                raise CursorNotFound(errmsg, code, response)

            msg = msg or "%s"
            raise OperationFailure(msg % errmsg, code, response)
996467
def _get_error_response(self, exc):
        
        if exc.has_code(codes.UNAUTHORIZED):
            return self._get_auth_challenge(exc)
        else:
            if exc.has_code(codes.INTERNAL_SERVER_ERROR):
                logging.getLogger('devil').error('devil caught http error: ' + str(exc), exc_info=True)
            else:
                logging.getLogger('devil').error('devil caught http error: ' + str(exc))
            content = exc.content or ''
            return HttpResponse(content=content, status=exc.get_code_num())
998452
def check_response(response):
    
    if response.status_code < 200 or response.status_code > 300:
        raise ServerError('API requests returned with error: %s'
                          % response.status_code)

    try:
        response_text = loads(response.text)
    except ValueError:
        raise ServerError('The API did not returned a JSON string.')

    if not response_text:
        raise EmptyResponse()

    if 'failure' in response_text:
        if response_text['failure'] == 'Falscher Dateityp':
            raise UnsupportedFormat('Please look at picflash.org '
                                    'witch formats are supported')
        else:
            raise UnkownError(response_text['failure'])
823774
def _validate_response(self, response):
        
        try:
            response.raise_for_status()
        except HTTPError as http_error:
            raise BadRequestException(str(http_error))

        response_data = response.json()
        if response_data["status_code"] != self.RESPONSE_STATUS_OK:
            raise InvalidResponseException(
                "Response code {0}: {1}".format(
                    response_data["status_code"], response_data["error"]
                )
            )
719560
function checkForError(resp) {
  if ('code' in resp) {
    throw errors.create(
      errors.types.BAD_REQUEST,
      errors.formatErrMsg(resp, ''),
      {body: resp}
    )
  }
  return resp
}
856113
def _check_gle_response(result):
    """"""
    # Did getlasterror itself fail?
    _check_command_response(result)

    if result.get("wtimeout", False):
        # MongoDB versions before 1.8.0 return the error message in an "errmsg"
        # field. If "errmsg" exists "err" will also exist set to None, so we
        # have to check for "errmsg" first.
        raise WTimeoutError(result.get("errmsg", result.get("err")),
                            result.get("code"),
                            result)

    error_msg = result.get("err", "")
    if error_msg is None:
        return result

    if error_msg.startswith("not master"):
        raise NotMasterError(error_msg, result)

    details = result

    # mongos returns the error code in an error object for some errors.
    if "errObjects" in result:
        for errobj in result["errObjects"]:
            if errobj.get("err") == error_msg:
                details = errobj
                break

    code = details.get("code")
    if code in (11000, 11001, 12582):
        raise DuplicateKeyError(details["err"], code, result)
    raise OperationFailure(details["err"], code, result)
490711
def check_error(res, error_enum):
  """"""
  if res.HasField("error"):
    enum_name = error_enum.DESCRIPTOR.full_name
    error_name = error_enum.Name(res.error)
    details = getattr(res, "error_details", "<none>")
    raise RequestError("%s.%s: '%s'" % (enum_name, error_name, details), res)
  return res
337725
function isResponseError(response, callback) {
  if(response.error) {
    callback(new Error('Coinjar personal fair_rate api returned error: ' + response.error));
    return true;
  }
  if(!response.body) {
    callback(new Error('Coinjar personal fair_rate api returned error: No response body.'));
    return true;
  }
  return false;
}
593285
def check_errors(self, response, data):
        """"""
        if "error_id" in data:
            error_id = data["error_id"]
            if error_id in self.error_ids:
                raise self.error_ids[error_id](response)
        if "error_code" in data:
            error_code = data["error_code"]
            if error_code in self.error_codes:
                raise self.error_codes[error_code](response)
        if "error_code" in data or "error_id" in data:
            raise AppNexusException(response)
966770
def check_error(self, response):
        
        if response.status_code == 500:
            raise ServiceError("500 - " + response.content)

        if response.status_code == 503:
            if "DDoS protection by Cloudflare" in response.content:
                raise ServiceError("Foiled by Cloudfare's DDoS protection")
            raise ServiceError("503 - Temporarily out of service.")

        if response.status_code == 429:
            raise ServiceError("429 - Too many requests")

        if response.status_code == 404:
            raise ServiceError("404 - Not Found")

        if response.status_code == 400:
            raise ServiceError("400 - Bad Request")
912624
def error_response(error_type="Internal server error",
                   error_text=None,
                   status=400,
                   participant=None):
    """"""
    traceback.print_exc()
    print("Error: {}.".format(error_type))

    page = error_page(
        error_text=error_text,
        error_type=error_type,
        participant=participant)

    data = {
        "status": "error",
        "html": page
    }
    return Response(dumps(data), status=status, mimetype='application/json')
204660
def parse_error(self, response):
        " "

        # Check invalid credentials.
        if self.check_error(response, 'failure', 'INVALID_DATA'):
            raise self.CredentialsError(
                self.response_message(response, 'ERROR'))