Log an HTTP response.

@param array|WP_Error $response The HTTP response.
@param array          $args     HTTP request arguments.
@param string         $url      The request URL.
2499
public function log_http_response( $response, array $args, $url ) {
		$this->data['http'][ $args['_qm_key'] ]['end']      = microtime( true );
		$this->data['http'][ $args['_qm_key'] ]['response'] = $response;
		$this->data['http'][ $args['_qm_key'] ]['args']     = $args;
		if ( isset( $args['_qm_original_key'] ) ) {
			$this->data['http'][ $args['_qm_original_key'] ]['end']      = $this->data['http'][ $args['_qm_original_key'] ]['start'];
			$this->data['http'][ $args['_qm_original_key'] ]['response'] = new WP_Error( 'http_request_not_executed', sprintf(
				/* translators: %s: Hook name */
				__( 'Request not executed due to a filter on %s', 'query-monitor' ),
				'pre_http_request'
			) );
		}

		$this->data['http'][ $args['_qm_key'] ]['info']      = $this->info;
		$this->data['http'][ $args['_qm_key'] ]['transport'] = $this->transport;
		$this->info      = null;
		$this->transport = null;
	}
878476
protected function log(Args $args)
    {
        $message = sprintf("%s%s", $this->render($args), PHP_EOL);
        file_put_contents($this->getStream(), $message);
    }
1304215
protected function response($return, $url = '', $wait = 3, $header = [])
    {
        if ($return->isSuccess()) {
            $this->success($return->getMsg(), $url, $return->getData(), $wait, $header);
        } else {
            $this->error($return->getMsg(), $url, $return->getData(), $wait, $header);
        }
    }
95055
protected function error($msg = '', $url = null, $data = '', $wait = 3, array $header = [])
    {
        if (is_null($url)) {
            $url = $this->request->isAjax() ? '' : 'javascript:history.back(-1);';
        } elseif ('' !== $url && !strpos($url, '://') && 0 !== strpos($url, '/')) {
            $url = $this->request->scheme() . '://' . $this->request->host() . '/' . $url;
        }

        $type = $this->getResponseType();
        $result = [
            'code' => 0,
            'msg'  => $msg,
            'data' => $data,
            'url'  => $url,
            'wait' => $wait,
        ];

        if ('view' == strtolower($type)) {

            $this->assign('code', $result['code']);
            $this->assign('msg', $result['msg']);
            $this->assign('data', $result['data']);
            $this->assign('url', $result['url']);
            $this->assign('wait', $result['wait']);
            $result = $this->display(Config::get('dispatch_error_tmpl'));
        }

        HttpResponse::create($result, $type)->header($header)->send();
    }
703071
public function addError(...$args) {
        $args = func_get_args();
        if(func_num_args()>2){
            foreach ($args as $error) {
                array_push($this->errors, $error);
            }
        } else {
            if(func_get_args()==1) {
                $this->errors[] = $args[0];
            } else {
                $this->errors[$args[0]] = $args[1];
            }
        }
    }
556449
private function setErrorFromResponse(Response $response)
    {
        $this->statusCode = $response->getStatus();
        $body = $response->getBody();
        if (isset($body['ErrorInfo'])) {
            $this->errorInfo = $body['ErrorInfo'];
        }
        if (isset($body['ErrorMessage'])) {
            $this->errorMessage = $body['ErrorMessage'];
        }
        if (isset($body['ErrorIdentifier'])) {
            $this->errorIdentifier = $body['ErrorIdentifier'];
        }
    }
832597
public static function err($message, ...$args) {
        if (count($args) > 0) {
            $message = call_user_func_array(
                'sprintf',
                array_merge([$message], $args)
            );
        }

        fwrite(STDERR, $message . PHP_EOL);
    }
117490
function(err) {

        var message = 'Error occured while performing a JSON-WSP request. ' +
            err.message + '\n' +
            JSON.stringify({
                options : curOpts
            }, null, '  ').yellow;

        logger.error(message);
    }
727914
private function hasError(array $response): bool
    {
        if (isset($response[self::ERROR])) {
            $this->errorMessage = $response[self::ERROR][self::ERROR_MESSAGE] ?? null;
            $this->errorType = $response[self::ERROR][self::ERROR_TYPE] ?? null;
            $this->errorCode = $response[self::ERROR][self::ERROR_CODE] ?? null;
            $this->errorSubcode = $response[self::ERROR][self::ERROR_SUBCODE] ?? null;
            $this->errorFbtraceId = $response[self::ERROR][self::ERROR_FBTRACE_ID] ?? null;

            return true;
        }

        return false;
    }
711734
def log_error(self, msg, *args):
        """"""
        if self._logger is not None:
            self._logger.error(msg, *args)
        else:
            print(msg % args)
702785
public function listAction(Request $request, Response $response, array $args)
    {
        $entities = $this->em->getRepository($this->entityClass)->findAll();

        $response->setContent($this->twig->render($this->views['list'], [
            'entities' => $entities
        ]));

        return $response;
    }
640008
function (error, response) {
        if (!_.isNull(error)) {
            error = _.createError(error);
        } else if (!_.isNull(response) && (response.status >= 400 || response.status === 0)) {
            error = _.createError(null, response);
            response = null;
        }
        callback(error, response);
    }
1090789
public static void error(String msg, Object... args) {
		String tag = generateTag();
		if (!"".equals(tag)) {
			if (args.length > 0) {
				Log.e(tag, String.format(msg, args));
			} else {
				Log.e(tag, msg);

			}
		}
	}
1166540
public function error($label, $arguments = [])
    {
        $log_message = 'Error code: ' . $label;
        if ($arguments) {
            $log_message .= ', arguments: ' . json_encode($arguments);
        }
        Log::info($log_message);

        if($this->isAjaxRequest()) {
            $error_object = [
                'id' => 'server',
                'code' => '500',
                'message' => $label,
                'arguments' => $arguments
            ];

            echo json_encode([
                'errors' => [$error_object],
            ]);
        } else {
            echo "<h2>Server error: {$label}</h2>";
        }

        exit;
    }
208772
private function log_http_error( $data, $context, $class, array $args = [], $url = '' ) {

		$msg      = 'WP HTTP API Error';
		$response = is_array( $data ) && isset( $data[ 'response' ] ) && is_array( $data[ 'response' ] )
			? shortcode_atts( [ 'message' => '', 'code' => '', 'body' => '' ], $data[ 'response' ] )
			: [ 'message' => '', 'code' => '', 'body' => '' ];

		if ( is_wp_error( $data ) ) {
			$msg .= ': ' . $data->get_error_message();
		} elseif ( is_string( $response[ 'message' ] ) && $response[ 'message' ] ) {
			$msg .= ': ' . $response[ 'message' ];
		}

		$log_context = [
			'transport'  => $class,
			'context'    => $context,
			'query_args' => $args,
			'url'        => $url,
		];

		if ( $response[ 'body' ] && is_string( $response[ 'body' ] ) ) {
			$log_context[ 'response_body' ] = strlen( $response[ 'body' ] ) <= 300
				? $response[ 'body' ]
				: substr( $response[ 'body' ], 0, 300 ) . '...';
		}

		if ( array_key_exists( 'code', $response ) && is_scalar( $response[ 'code' ] ) ) {
			$msg .= " - Response code: {$response[ 'code' ]}";
			( is_array( $data ) && ! empty( $data[ 'headers' ] ) ) and $log_context[ 'headers' ] = $data[ 'headers' ];
		}

		return new Error( rtrim( $msg, '.' ) . '.', Channels::HTTP, $log_context );
	}
1362466
public function log(Request $request, Response $response): void
    {
        $host = $request->url();
        $method = $request->method();
        $agent = $request->userAgent();
        $date = $this->date($response->getDate());
        $status = $response->status();
        $style = $this->style($status);

        $this->output->writeln(
            sprintf("%s %s %s <$style>%d</$style> %s", $host, $date, $method, $status, $agent)
        );
    }
182493
function errorHandler(response) {
        if (response) {
          var errorData = _buildError(xhr, url, method, response);
          Logger.error(errorData);

          if (errorCallback) {
            Logger.warnCallbackDeprecation();
            errorCallback(errorData);
          }
          reject(errorData);
        }
      }