Process an API error, updating the data structure
961515
def _error_detail(data, item):
    '''
    
    '''
    err = item['errorDetail']
    if 'code' in err:
        try:
            msg = ': '.join((
                item['errorDetail']['code'],
                item['errorDetail']['message']
            ))
        except TypeError:
            msg = '{0}: {1}'.format(
                item['errorDetail']['code'],
                item['errorDetail']['message'],
            )
    else:
        msg = item['errorDetail']['message']
    data.append(msg)
993310
def handle_error(r, expected_code):
    
    code = r.status_code
    if code != expected_code:
        info = 'API response status code {}'.format(code)
        try:
            if 'detail' in r.json():
                info = info + ": {}".format(r.json()['detail'])
            elif 'metadata' in r.json():
                info = info + ": {}".format(r.json()['metadata'])
        except json.decoder.JSONDecodeError:
            info = info + ":\n{}".format(r.content)
        raise Exception(info)
1361416
def handle_exception(error):
        
        response = jsonify(error.to_dict())
        response.status_code = error.status_code
        return response
758420
def raise_for_api_error(headers: MutableMapping, data: MutableMapping) -> None:
    

    if not data["ok"]:
        raise exceptions.SlackAPIError(data.get("error", "unknow_error"), headers, data)

    if "warning" in data:
        LOG.warning("Slack API WARNING: %s", data["warning"])
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))
41476
def _raise_on_error(data):
    """"""
    if isinstance(data, list):
        data = data[0]

    if isinstance(data, dict) and 'error' in data:
        raise_error(data['error'])
730689
function apiError(response, error) {
  var content = errorContentExt(ErrorType.server, error);
  send(response, content, StatusCode.internalServerError);
}
309824
function APIError(message, type, field) {
  Error.call(this);
  Error.captureStackTrace(this, arguments.callee);
  this.name = 'APIError';
  this.message = message;
  this.type = type;
  this.field = field;
}
217170
def handle_error(self, error, req, schema, error_status_code, error_headers):
        """"""
        status = status_map.get(error_status_code or self.DEFAULT_VALIDATION_STATUS)
        if status is None:
            raise LookupError("Status code {0} not supported".format(error_status_code))
        raise HTTPError(status, errors=error.messages, headers=error_headers)
558815
static void processError(String type, String errString, HttpServerExchange exchange) {
        exchange.setStatusCode(StatusCodes.INTERNAL_SERVER_ERROR);
        exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, CONTENT_TYPE);
        exchange.getResponseHeaders().add(new HttpString("Version"), VERSION_PROTOCOL);
        exchange.getResponseHeaders().add(new HttpString("Type"), type);
        exchange.getResponseHeaders().add(new HttpString("Mess"), errString);
        exchange.endExchange();
        UndertowLogger.ROOT_LOGGER.mcmpProcessingError(type, errString);
    }
586270
def handle_query_error(msg, query, session, payload=None):
    """"""
    payload = payload or {}
    troubleshooting_link = config['TROUBLESHOOTING_LINK']
    query.error_message = msg
    query.status = QueryStatus.FAILED
    query.tmp_table_name = None
    session.commit()
    payload.update({
        'status': query.status,
        'error': msg,
    })
    if troubleshooting_link:
        payload['link'] = troubleshooting_link
    return payload
113497
function processError (error) {
    if (_cb.beforeReturnError) { _cb.beforeReturnError(error); }
    if (_cb.returnError) { _cb.returnError(error, response); }
    if (_cb.afterReturnError) { _cb.afterReturnError(error); }
  }
580100
function handleError(err) {
  if (typeof err === 'string' && errors[err]) {
    console.error(errors[err]);
  } else {
    if (argv.verbose) {
      console.error(err.stack);
    } else {
      console.error(err.message);
    }
  }
  process.exit(1);
}
447233
def handle_errors(resp):
    """"""
    if resp.status_code == 400:
        raise ApiException(json.loads(resp.content).get('message'))
    return resp
655368
private void handleErrorResponse(String jsonResponse)
			throws MusixMatchException {
		StatusCode statusCode;
		Gson gson = new Gson();

		System.out.println(jsonResponse);

		ErrorMessage errMessage = gson.fromJson(jsonResponse,
				ErrorMessage.class);
		int responseCode = errMessage.getMessageContainer().getHeader()
				.getStatusCode();

		switch (responseCode) {
		case 400:
			statusCode = StatusCode.BAD_SYNTAX;
			break;
		case 401:
			statusCode = StatusCode.AUTH_FAILED;
			break;
		case 402:
			statusCode = StatusCode.LIMIT_REACHED;
			break;
		case 403:
			statusCode = StatusCode.NOT_AUTHORIZED;
			break;
		case 404:
			statusCode = StatusCode.RESOURCE_NOT_FOUND;
			break;
		case 405:
			statusCode = StatusCode.METHOD_NOT_FOUND;
			break;
		default:
			statusCode = StatusCode.ERROR;
			break;
		}

		throw new MusixMatchException(statusCode.getStatusMessage());
	}
1288116
function throwError(res, errorCode) {
    const error = decodeError(errorCode);
    res.writeHead(error.status, { 'Content-Type': 'application/json' });
    res.write(JSON.stringify(error));
    res.end();
}
296464
def handle_request_parsing_error(
        err,
        _req,
        _schema,
        _err_status_code,
        _err_headers,
):
    
    abort(HTTPStatus.BAD_REQUEST, errors=err.messages)