Analyze errors from response

@return void
489447
protected function analyzeResponseErrors()
    {
        $content = $this->content;

        if ($content && property_exists($content, 'errors')) {
            $this->setErrors($content, 'errors');
        } elseif ($content && property_exists($content, 'ERROR')) {
            $this->setError('Unknown', $content->ERROR);
        }

        $this->throwExceptions();
    }
369571
def __analizar_errores(self, ret):
        ""
        errores = []
        if 'errores' in ret:
            errores.extend(ret['errores'])
        if errores:
            self.Errores = ["%(codigo)s: %(descripcion)s" % err['error'][0]
                            for err in errores]
            self.errores = [
                {'codigo': err['error'][0]['codigo'],
                 'descripcion': err['error'][0]['descripcion'].replace("\n", "")
                                .replace("\r", "")} 
                             for err in errores]
            self.ErrCode = ' '.join(self.Errores)
            self.ErrMsg = '\n'.join(self.Errores)
762953
public static function checkErrors()
    {
        if (self::STATUS_SHUTDOWN != self::$_status) {
            $error_msg = 'Worker['. getmypid() .'] process terminated with ';
            $errors    = error_get_last();
            if ($errors && ($errors['type'] === E_ERROR ||
                    $errors['type'] === E_PARSE ||
                    $errors['type'] === E_CORE_ERROR ||
                    $errors['type'] === E_COMPILE_ERROR ||
                    $errors['type'] === E_RECOVERABLE_ERROR)
            ) {
                $error_msg .= self::getErrorType($errors['type']) . " \"{$errors['message']} in {$errors['file']} on line {$errors['line']}\"";
            } else {
                $error_msg .= 'exit()/die(). Please do not call exit()/die() in workerman.';
            }
            self::log($error_msg);
        }
    }
514239
public function processResponse()
    {
        // Init results
        $results = [];

        foreach ($this->packets_response as $response) {
            $buffer = new Buffer($response);

            // Figure out what packet response this is for
            $response_type = $buffer->read(6);

            // Figure out which packet response this is
            if (!array_key_exists($response_type, $this->responses)) {
                throw new Exception(__METHOD__ . " response type '" . bin2hex($response_type) . "' is not valid");
            }

            // Now we need to call the proper method
            $results = array_merge(
                $results,
                call_user_func_array([$this, $this->responses[$response_type]], [$buffer])
            );

            unset($buffer);
        }

        return $results;
    }
920451
private function privateErrors() : array
    {
        $errors = [];
        if (isset($this->tests)) {
            foreach ($this->tests as $error => $test) {
                if (!$test((array)$this)) {
                    $errors[] = $error;
                }
            }
        }
        return $errors;
    }
1220666
function httpError($code, Swoole\Response $response, $content = '')
    {
        $response->setHttpStatus($code);
        $response->head['Content-Type'] = 'text/html';
        $response->body = Swoole\Error::info(Swoole\Response::$HTTP_HEADERS[$code],
            "<p>$content</p><hr><address>" . self::SOFTWARE . " at {$this->server->host}" .
            " Port {$this->server->port}</address>");
    }
97431
public static function checkError()
    {
        switch (json_last_error()) {
            case JSON_ERROR_NONE:
                $msg = null;
                break;
            case JSON_ERROR_DEPTH:
                $msg = 'Maximum stack depth exceeded';
                break;
            case JSON_ERROR_STATE_MISMATCH:
                $msg = 'Underflow or the modes mismatch';
                break;
            case JSON_ERROR_CTRL_CHAR:
                $msg = 'Unexpected control character found';
                break;
            case JSON_ERROR_SYNTAX:
                $msg = 'Syntax error, malformed JSON';
                break;
            case JSON_ERROR_UTF8:
                $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
                break;
            default:
                $msg = 'Unknown error';
                break;
        }
        return $msg;
    }
258187
private function error_to_response( $error ) {
		$error_data = $error->get_error_data();
		if ( is_array( $error_data ) && isset( $error_data['status'] ) ) {
			$status = $error_data['status'];
		} else {
			$status = 500;
		}

		$errors = [];
		foreach ( (array) $error->errors as $code => $messages ) {
			foreach ( (array) $messages as $message ) {
				$errors[] = [ 'code' => $code, 'message' => $message, 'data' => $error->get_error_data( $code ) ];
			}
		}

		$data = $errors[0];
		if ( count( $errors ) > 1 ) {
			array_shift( $errors );
			$data['additional_errors'] = $errors;
		}
		$response = new \WP_REST_Response( $data, $status );

		return $response;
	}
664624
public function checkError(ResponseInterface $response)
    {
        if ($response->getStatusCode() < 400) {
            return $response;
        }

        //check if any limit was hit
        $this->checkUserRateLimit($response);
        $this->checkClientRateLimit($response);
        $this->checkPostRateLimit($response);

        $body = (string) $response->getBody();
        $responseData = json_decode($body, true);
        if (JSON_ERROR_NONE !== json_last_error()) {
            $responseData = $body;
        }

        if (\is_array($responseData) && isset($responseData['data']) && isset($responseData['data']['error'])) {
            $errorMessage = $responseData['data']['error'];
            // when uploading too fast, error is an array
            if (\is_array($responseData['data']['error'])) {
                $errorMessage = '';

                if (isset($responseData['data']['error']['message'])) {
                    $errorMessage = $responseData['data']['error']['message'];
                } elseif (isset($responseData['data']['error']['code'])) {
                    $errorMessage = 'Error code: ' . $responseData['data']['error']['code'];
                }
            }

            $message = 'Request failed with: "' . $errorMessage . '"';
            if (isset($responseData['data']['request'])) {
                $message = 'Request to: ' . $responseData['data']['request'] . ' failed with: "' . $errorMessage . '"';
            }

            throw new ErrorException($message, $response->getStatusCode());
        }

        throw new RuntimeException(\is_array($responseData) && isset($responseData['message']) ? $responseData['message'] : $responseData, $response->getStatusCode());
    }
399953
public function getValidationErrors()
    {
        $errors = [];
        if (isset($this->response->errors)) {
            foreach ($this->response->errors as $error => $reasons) {
                $errors[] = [
                    'attribute' => $error,
                    'reason'    => $this->getValidationReasonsAsString($reasons),
                ];
            }
        }

        return $errors;
    }
602091
public function processResponse()
    {
        // Holds the processed packets so we can sort them in case they come in an unordered
        $processed = [];

        // Iterate over the packets
        foreach ($this->packets_response as $response) {
            // Check to see if we had a preg_match error
            if (($match = preg_match("#^(.*)\\\\queryid\\\\([^\\\\]+)(\\\\|$)#", $response, $matches)) === false
                || $match != 1
            ) {
                throw new Exception(__METHOD__ . " An error occurred while parsing the packets for 'queryid'");
            }

            // Multiply so we move the decimal point out of the way, if there is one
            $key = (int)(floatval($matches[2]) * 1000);

            // Add this packet to the processed
            $processed[$key] = $matches[1];
        }

        // Sort the new array to make sure the keys (query ids) are in the proper order
        ksort($processed, SORT_NUMERIC);

        // Create buffer and offload processing
        return $this->processStatus(new Buffer(implode('', $processed)));
    }
265753
protected function processResponse()
    {
        $body = $this->response->getBody();

        // Look for UTF-8 BOM and remove.
        if (0 === strpos(bin2hex(substr($body, 0, 4)), 'efbbbf')) {
            $body = substr($body, 3);
        }

        $parsedResponse = \json_decode($body);

        // Test if return a valid JSON.
        if (JSON_ERROR_NONE !== json_last_error()) {
            $message = function_exists('json_last_error_msg') ? json_last_error_msg() : 'Invalid JSON returned';
            throw new HttpClientException(
                sprintf('JSON ERROR: %s', $message),
                $this->response->getCode(),
                $this->request,
                $this->response
            );
        }

        $this->lookForErrors($parsedResponse);

        return $parsedResponse;
    }
394651
private function check_errors() {
 	 	switch($this->db['phptype']) {
 	 		case "sqlite":
				if ($this->sqlite_version == 3) {
					$this->errno = $this->conn->lastErrorCode();
					$this->error = $this->conn->lastErrorMsg();
				} else {
					$this->errno = sqlite_last_error($this->conn);
					$this->error = sqlite_error_string($this->errno);
				}
 	 			break;
 	 		case "mysql":
 	 			$this->errno = mysql_errno($this->conn);
 	 			$this->error = mysql_error($this->conn);
 	 			break;
 	 		case "mysqli":
				if (mysqli_connect_error()) {
					die('Connect Error: ' . mysqli_connect_error());
				}
 	 			$this->errno = mysqli_errno($this->conn);
 	 			$this->error = mysqli_error($this->conn);
 	 			break;
 	 	}

 	}
1344801
public function error()
    {

        $res = $this->response();

        if (!$res) {
            return null;
        }

        if ($this->ok()) {
            return null;
        }

        $message = ($res->getStatusCode() ? $res->getStatusCode() . ' ' : '') .
                   ($res->getReasonPhrase() ? $res->getReasonPhrase() : 'Unknown response reason phrase');

        try {

            $data = $this->json();

            if (!empty($data->message)) {
                $message = $data->message;
            }

            if (!empty($data->error_description)) {
                $message = $data->error_description;
            }

            if (!empty($data->description)) {
                $message = $data->description;
            }

        } catch (Exception $e) {
            // This should never happen
            $message .= ' (and additional error happened during JSON parse: ' . $e->getMessage() . ')';
        }

        return $message;

    }
523644
public static function error()
    {
        $response = response(Admin::content()->withError(trans('admin.deny')));

        if (!request()->pjax() && request()->ajax()) {
            abort(403, trans('admin.deny'));
        }

        Pjax::respond($response);
    }
1190869
public static function parseErrorsFromResponse(HttpResponse $response)
    {
        $json = $response->getJsonResult();
        $errorStr = '';
        if (isset($json->errors)
            && is_array($json->errors)
            && !empty($json->errors)
        ) {
            foreach ($json->errors as $stdClassError) {
                if (isset($stdClassError->errors)) {
                    $errorStr .= $stdClassError->errors;
                }
                if (isset($stdClassError->product_id)) {
                    $errorStr .= sprintf('(product #%s)', $stdClassError->product_id);
                }
            }
        }

        return $errorStr;
    }
655474
public function getErrors()
    {
        $aErrors = Array();
        if (empty( $this->_errors )) {
            if (is_array($this->_getField(self::$ERROR))) {
                foreach ($this->_getField(self::$ERROR) as $error) {
                    $errorCode       = isset( $error[self::$ERROR_CODE] ) ? $error[self::$ERROR_CODE] : 0;
                    $message         = isset( $error[self::$ERROR_MESSAGE] ) ? $error[self::$ERROR_MESSAGE] : '';
                    $consumerMessage = isset( $error[self::$ERROR_CONSUMER_MESSAGE] ) ? $error[self::$ERROR_CONSUMER_MESSAGE] : '';
                    $paySysMessage   = isset( $error[self::$ERROR_PAYSYS_MESSAGE] ) ? $error[self::$ERROR_PAYSYS_MESSAGE] : '';

                    $error = new WirecardCEE_QMore_Error($errorCode, $message);
                    $error->setConsumerMessage($consumerMessage);
                    $error->setPaySysMessage($paySysMessage);

                    $aErrors[] = $error;
                }
            }

            $this->_errors = $aErrors;
        }

        return $this->_errors;
    }