/*
单个接口出错处理
@param  {String} _bid   请求标识
@param  {String} _cid   接口标识
@param  {Object} _error 错误信息
@return {Void}
559104
function(_bid,_cid,_error){
        var _batch = _xcache[_bid];
        if (!_batch||_doFilter(_error)) return;
        var _handler = _batch.h[_cid];
        if (!_handler) return;
        try{
            (_handler.e||f)(_error);
        }catch(ex){
            // ignore
            if (DEBUG) throw ex;
            console.error(ex.message);
            console.error(ex);
        }
    }
763982
function Bid(value) {
  if (this.init_) {
    this.init_();
  }
  /** @property {Array.<number, number>} [sizes] the dimension sizes of the slot bid */
  this.sizes =  [];
  /** @property {string} [slot] the slot name */
  this.slot;
  /** @property {string|number} value the bid value. Default: empty string */
  this.value = util.asType(value) === 'undefined' ? '' : value;
  /** @property {string} type derived bid value type: from {@link util.asType}  */
  this.type = util.asType(this.value);
  /** @property {string} [label] optional label for adserver key targeting for bid value e.g. <code>label=2.00</code> */
  this.label;
  /** @property {string} [provider] the bid provider name */
  this.provider;
  /** @property {object} [targeting] ad server targeting key/values in addition to the bid value */
  this.targeting = {};
}
824251
function insertQueryError(err, tx) {
        CRUD.stats.writesExecuted++;
        console.error("Insert query error: ", err);
        return err;
    }
884208
function errorPage(res, err) {
		if (err) {
			console.error(err.message);
			res.send(err, {'Content-Type': 'text/plain'}, 500);
		} else {
			res.send(404);
		}
	}
166008
function(bid) {
    const siteId = bid.params.siteId || '';
    if (!siteId) {
      utils.logError(LOG_MSG.noSite);
    }
    return !!(bid.adUnitCode && siteId);
  }
200587
function (error) {
        send(channel, new MSG.OpenResult(msg.tcpId, Protocol.toOpenResultStatus(error), null, null));
      }
151056
public function onSwooleWorkerError($serv, $worker_id, $worker_pid, $exit_code)
    {
        $data = ['worker_id' => $worker_id,
            'worker_pid' => $worker_pid,
            'exit_code' => $exit_code];
        $log = "WORKER Error ";
        $log .= json_encode($data);
        $this->log->alert($log);
        if ($this->onErrorHandel != null) {
            sd_call_user_func($this->onErrorHandel, '【！！！】服务器进程异常退出', $log);
        }
    }
80637
function (bidRequests, bidderRequest) {
    const topLocation = utils.getTopWindowLocation();
    const payload = {
      id: bidRequests[0].auctionId,
      site: {
        domain: window.location.protocol + '//' + topLocation.hostname,
        name: topLocation.hostname,
        page: topLocation.href,
      },
      device: {
        ua: navigator.userAgent,
        language: navigator.language,
        devicetype: isMobile() ? 1 : isConnectedTV() ? 3 : 2,
      },
      imp: bidRequests.map(mapImpression)
    };

    if (bidderRequest && bidderRequest.gdprConsent) {
      payload.user = {ext: {consent: bidderRequest.gdprConsent.consentString}};
      const gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0;
      payload.regs = {ext: {gdpr: gdpr}};
    }

    return {
      method: 'POST',
      url: URL,
      data: JSON.stringify(payload),
      bidderRequest
    };
  }
1223226
function formatBidRequest(bid, bidderRequest) {
  let url = urlTemplate({
    adapter: 'prebid',
    slot: bid.params.slot,
    adkey: bid.params.adkey,
    ad_size: bid.params.ad_size,
    location: encodeURIComponent(utils.getTopWindowLocation()),
    referrer: encodeURIComponent(utils.getTopWindowReferrer()),
    wn: boolToString(/fb_http/i.test(window.name)),
    sf: boolToString(window['sfAPI'] || window['$sf']),
    fif: boolToString(window['inDapIF'] === true),
    if: boolToString(window !== window.top),
    stamp: new Date().getTime(),
    hbver: ADAPTER_VERSION
  });

  if (bidderRequest && bidderRequest.gdprConsent) {
    if (bidderRequest.gdprConsent.gdprApplies !== undefined) {
      const gdpr = '&__gdpr=' + (bidderRequest.gdprConsent.gdprApplies ? '1' : '0');
      url += gdpr;
    }
    if (bidderRequest.gdprConsent.consentString !== undefined) {
      url += '&__consent=' + bidderRequest.gdprConsent.consentString;
    }
  }

  return {
    method: 'GET',
    url: url,
    bidId: bid.bidId
  };
}
166440
function(serverResponse, {bidderRequest}) {
    serverResponse = serverResponse.body;
    const bids = [];
    if (!serverResponse || serverResponse.error) {
      let errorMessage = `in response for ${bidderRequest.bidderCode} adapter`;
      if (serverResponse && serverResponse.error) { errorMessage += `: ${serverResponse.error}`; }
      utils.logError(errorMessage);
      return bids;
    }

    if (serverResponse.tags) {
      serverResponse.tags.forEach(serverBid => {
        const rtbBid = getRtbBid(serverBid);
        if (rtbBid) {
          if (rtbBid.cpm !== 0 && includes(this.supportedMediaTypes, rtbBid.ad_type)) {
            const bid = newBid(serverBid, rtbBid, bidderRequest);
            bid.mediaType = parseMediaType(rtbBid);
            bids.push(bid);
          }
        }
      });
    }
    return bids;
  }
95760
function (bidRequests, bidderRequest) {
    let normalizedBids = bidRequests.map((bidRequest) => {
      return getNormalizedBidRequest(bidRequest);
    });

    let idClient = new ImproveDigitalAdServerJSClient('hb');
    let requestParameters = {
      singleRequestMode: (config.getConfig('improvedigital.singleRequest') === true),
      returnObjType: idClient.CONSTANTS.RETURN_OBJ_TYPE.URL_PARAMS_SPLIT,
      libVersion: this.version
    };

    if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString) {
      requestParameters.gdpr = bidderRequest.gdprConsent.consentString;
    }

    let requestObj = idClient.createRequest(
      normalizedBids, // requestObject
      requestParameters
    );

    if (requestObj.errors && requestObj.errors.length > 0) {
      utils.logError('ID WARNING 0x01');
    }

    return requestObj.requests;
  }
262165
public void queryError(OutputStream os,
                         HeadersAmp headers,
                         String address,
                         long qId,
                         Throwable exn)
    throws IOException
  {
    init(os);

    OutH3 out = _out;

    if (out == null)
      return;

    if (log.isLoggable(_level)) {
      log.log(_level, "query-error " + exn
                 + " (in " + this + ")" + " {to:" + address + ", " + headers + "}");
      
      if (log.isLoggable(Level.FINEST)) {
        log.log(Level.FINEST, exn.toString(), exn);
      }
    }

    try {
      out.writeLong(MessageTypeHamp.QUERY_ERROR.ordinal());
      writeHeaders(out, headers);
      
      writeToAddress(out, address);
      out.writeLong(qId);

      ErrorAmp error = ErrorAmp.create(exn);

      out.writeString(error.getCode().toString());
      out.writeString(error.getMessage());
      out.writeObject(error.getDetail());

      // XXX: out.flushBuffer();
    } catch (Throwable e) {
      log.log(Level.WARNING, e.toString(), e);
      
      throw e;
    }
  }
532782
function clientError(err, res) {
  log('error', err.message, { stack: err.stack });
  // They know it's a 400 already, we don't need to repeat the fact that its an error.
  const message = removePrefix(err.message, ':'),
    code = 400;

  sendDefaultResponseForCode(code, message, res);
}
1326823
function onError( error ) {
		debug( 'Error encountered while querying endpoint: %s', error.message );
		if ( error instanceof Error ) {
			err = {
				'status': 500,
				'message': 'Request error: ' + error.message
			};
			return clbk( err );
		}
		return clbk( error, res, body );
	}
1354777
function(bidRequests, bidderRequest) {
    // var currency = config.getConfig(currency);

    var currentBidRequest = bidRequests[0];
    if (bidRequests.length > 1) {
      utils.logMessage('Prebid.JS - freewheel bid adapter: only one ad unit is required.');
    }

    var zone = currentBidRequest.params.zoneId;
    var timeInMillis = new Date().getTime();
    var keyCode = hashcode(zone + '' + timeInMillis);

    var requestParams = {
      reqType: 'AdsSetup',
      protocolVersion: '2.0',
      zoneId: zone,
      componentId: getComponentId(currentBidRequest.params.format),
      timestamp: timeInMillis,
      pKey: keyCode
    };

    // Add GDPR flag and consent string
    if (bidderRequest.gdprConsent) {
      requestParams._fw_gdpr_consent = bidderRequest.gdprConsent.consentString;

      if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') {
        requestParams._fw_gdpr = bidderRequest.gdprConsent.gdprApplies;
      }
    }

    if (currentBidRequest.params.gdpr_consented_providers) {
      requestParams._fw_gdpr_consented_providers = currentBidRequest.params.gdpr_consented_providers;
    }

    var vastParams = currentBidRequest.params.vastUrlParams;
    if (typeof vastParams === 'object') {
      for (var key in vastParams) {
        if (vastParams.hasOwnProperty(key)) {
          requestParams[key] = vastParams[key];
        }
      }
    }

    var location = utils.getTopWindowUrl();
    if (isValidUrl(location)) {
      requestParams.loc = location;
    }

    var playerSize = getBiggerSize(currentBidRequest.sizes);
    if (playerSize[0] > 0 || playerSize[1] > 0) {
      requestParams.playerSize = playerSize[0] + 'x' + playerSize[1];
    }

    return {
      method: 'GET',
      url: FREEWHEEL_ADSSETUP,
      data: requestParams,
      bidRequest: currentBidRequest
    };
  }
156609
function debug( err, req, res, next ) {
        res.status( err.status || 500 );

        err.guid = uuid.v4();

        console.error( err );

        res.json( {
            error: err.message,
            message: err.userMessage,
            handled: err.handled || false,
            guid: err.guid,
            stack: err.stack
        } );
    }
344888
function(validBidRequests, bidderRequest) {
    const auids = [];
    const bidsMap = {};
    const slotsMapByUid = {};
    const sizeMap = {};
    const bids = validBidRequests || [];
    let priceType = 'net';
    let reqId;

    bids.forEach(bid => {
      if (bid.params.priceType === 'gross') {
        priceType = 'gross';
      }
      reqId = bid.bidderRequestId;
      const {params: {uid}, adUnitCode} = bid;
      auids.push(uid);
      const sizesId = utils.parseSizesInput(bid.sizes);

      if (!slotsMapByUid[uid]) {
        slotsMapByUid[uid] = {};
      }
      const slotsMap = slotsMapByUid[uid];
      if (!slotsMap[adUnitCode]) {
        slotsMap[adUnitCode] = {adUnitCode, bids: [bid], parents: []};
      } else {
        slotsMap[adUnitCode].bids.push(bid);
      }
      const slot = slotsMap[adUnitCode];

      sizesId.forEach((sizeId) => {
        sizeMap[sizeId] = true;
        if (!bidsMap[uid]) {
          bidsMap[uid] = {};
        }

        if (!bidsMap[uid][sizeId]) {
          bidsMap[uid][sizeId] = [slot];
        } else {
          bidsMap[uid][sizeId].push(slot);
        }
        slot.parents.push({parent: bidsMap[uid], key: sizeId, uid});
      });
    });

    const payload = {
      u: utils.getTopWindowUrl(),
      pt: priceType,
      auids: auids.join(','),
      sizes: utils.getKeys(sizeMap).join(','),
      r: reqId,
      wrapperType: 'Prebid_js',
      wrapperVersion: '$prebid.version$'
    };

    if (bidderRequest) {
      if (bidderRequest.timeout) {
        payload.wtimeout = bidderRequest.timeout;
      }
      if (bidderRequest.gdprConsent) {
        if (bidderRequest.gdprConsent.consentString) {
          payload.gdpr_consent = bidderRequest.gdprConsent.consentString;
        }
        payload.gdpr_applies =
          (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean')
            ? Number(bidderRequest.gdprConsent.gdprApplies) : 1;
      }
    }

    return {
      method: 'GET',
      url: ENDPOINT_URL,
      data: utils.parseQueryStringParameters(payload).replace(/\&$/, ''),
      bidsMap: bidsMap,
    };
  }