Returns an object or array of the FDC error parsed from the Guzzle Request exception

@param RequestException $requestException
@param bool             $isAssoc

@return string
11784
public static function parseError(RequestException $requestException, $isAssoc = true)
	{

		$error = $error = json_decode($requestException->getResponse()->getBody(), $isAssoc);

		if (!is_null($error))
		{
			return $error;
		}
		else
		{
			return $requestException->getMessage();
		}
	}
675559
public function getOAuthCallbackAction(Request $request)
    {
        $this->initSessionBag();

        if ($request->query->get("state") != $this->sessionBag->get("hash")) {
            throw new UserException("Invalid session verification hash");
        }

        $guzzle = new GuzzleClient();
        try {
            $response = $guzzle->post($this->getTokenUrl(), array("body" => array(
                "client_id" => $this->getClientId(),
                "client_secret" => $this->getClientSecret(),
                "grant_type" => $this->grantType,
                "redirect_uri" => $this->getCallbackUrl($request),
                "code" => $request->query->get("code")
            )));
        } catch (ClientException $e) {
            $errCode = $e->getResponse()->getStatusCode();
            if ($errCode == 400) {
                $desc = jsonDecode($e->getResponse()->getBody(true), true);
                $code = empty($desc["code"]) ? 0 : $desc["code"];
                $message = empty($desc["error_message"]) ? "Unknown error from API." : $desc["error_message"];

                throw new UserException(
                    "OAuth authentication failed[{$code}]: {$message}",
                    null,
                    [
                        'response' => $e->getResponse()->getBody()
                    ]
                );
            } else {
                throw $e;
            }
        }

        $responseData = jsonDecode($response->getBody(true));

        $this->storeOAuthData($responseData);
        return $this->returnResult($responseData);
    }
954682
protected function _getDemoShopLoginQuery($sUser, $sPassword)
    {
        if ($sPassword == "admin" && $sUser == "admin") {
            $sSelect = "SELECT `oxid` FROM `oxuser` WHERE `oxrights` = 'malladmin' ";
        } else {
            /** @var UserException $oEx */
            $oEx = oxNew(UserException::class);
            $oEx->setMessage('ERROR_MESSAGE_USER_NOVALIDLOGIN');
            throw $oEx;
        }

        return $sSelect;
    }
671641
private function handleException(GuzzleExceptions\GuzzleException $exception, RequestInterface $request)
    {
        if ($exception instanceof GuzzleExceptions\SeekException) {
            return new HttplugException\RequestException($exception->getMessage(), $request, $exception);
        }

        if ($exception instanceof GuzzleExceptions\ConnectException) {
            return new HttplugException\NetworkException($exception->getMessage(), $exception->getRequest(), $exception);
        }

        if ($exception instanceof GuzzleExceptions\RequestException) {
            // Make sure we have a response for the HttpException
            if ($exception->hasResponse()) {
                return new HttplugException\HttpException(
                    $exception->getMessage(),
                    $exception->getRequest(),
                    $exception->getResponse(),
                    $exception
                );
            }

            return new HttplugException\RequestException($exception->getMessage(), $exception->getRequest(), $exception);
        }

        return new HttplugException\TransferException($exception->getMessage(), 0, $exception);
    }
795704
public static function request($name, $as_name = '', $is_throw = true) {
        $value = request()->param($name);
        if (!$as_name) {
            $as_name = $name;
        }
        $validate = new static();
        $validate->value = $value;
        $validate->as_name = $as_name;
        $validate->is_throw = $is_throw;
        return $validate;
    }
592114
protected function createException(GuzzleRequestException $exception): RequestException
    {
        if ($exception instanceof GuzzleResponseException) {
            return new ResponseException(
                $exception->getRequest(),
                $exception->getResponse(),
                $exception
            );
        }

        throw new RequestException(
            $exception->getRequest(),
            $exception
        );
    }
1263138
public static function wrapException(RequestInterface $request, \Exception $e)
    {
        if ($e instanceof RequestException) {
            return $e;
        } elseif ($e instanceof ConnectException) {
            return new HttpConnectException($e->getMessage(), $request, null, $e);
        } else {
            return new RequestException($e->getMessage(), $request, null, $e);
        }
    }
1153378
public function applyResponse(HttpRequestInterface $request, HttpResponseInterface $response, array $options)
    {
        if ($response instanceof ResponseInterface &&
            isset($options['rpc_error']) &&
            true === $options['rpc_error'] &&
            null !== $response->getRpcErrorCode()
        ) {
            throw RequestException::create($request, $response);
        }

        return $response;
    }
1079338
public function getErrorResponse($errors, int $statusCode = self::HTTP_BAD_REQUEST, array $headers = [])
    {
        if (\is_iterable($errors) === true) {
            /** @var iterable $errors */
            $content = $this->getEncoder()->encodeErrors($errors);
        } else {
            \assert($errors instanceof ErrorInterface);
            $content = $this->getEncoder()->encodeError($errors);
        }

        return $this->createJsonApiResponse($content, $statusCode, $headers, true);
    }
576154
public function getExceptionForFailedRequest(RequestInterface $request)
    {
        $oid = spl_object_hash($request);

        return isset($this->exceptionForRequest[$oid]) ? $this->exceptionForRequest[$oid] : null;
    }
157997
protected function getParsedResponse(RequestInterface $request): string
    {
        $response = $this->getHttpClient()->sendRequest($request);

        $statusCode = $response->getStatusCode();
        if (401 === $statusCode || 403 === $statusCode) {
            throw new InvalidCredentials();
        } elseif (429 === $statusCode) {
            throw new QuotaExceeded();
        } elseif ($statusCode >= 300) {
            throw InvalidServerResponse::create((string) $request->getUri(), $statusCode);
        }

        $body = (string) $response->getBody();
        if (empty($body)) {
            throw InvalidServerResponse::emptyResponse((string) $request->getUri());
        }

        return $body;
    }
930618
protected function convertExceptionToResponse(Exception $e, Request $request)
    {
        $debug = Config::get('app.debug');

        //
        $e = FlattenException::create($e);

        $handler = new SymfonyExceptionHandler($debug);

        return SymfonyResponse::create($handler->getHtml($e), $e->getStatusCode(), $e->getHeaders());
    }
551486
public function getCustomers(Get\RequestData $requestData = null)
    {
        $request = new Get\Request($requestData);

        $apiResponse = $this->sendRequest($request, Get\ApiResponse::class);

        /** @var Get\Response $response */
        $response = $apiResponse->getResponse();
        foreach ($response->getCustomers() as $customer) {
            if ($customer->getBirthday() instanceof \DateTime) {
                $customer->getBirthday()->setTime(0, 0, 0);
            }
        }

        return $apiResponse;
    }
1256485
public static function getException($transactionId, $responseCode, $responseText, $type)
    {
        $acceptedCodes = array('00', '0');
        $map = array();

        switch ($type) {
        case 'credit':
            $acceptedCodes = array_merge($acceptedCodes, array('85', '10'));
            $map = self::$_issuerCodeToCreditExceptionCode;
            break;
        case 'gift':
            $acceptedCodes = array_merge($acceptedCodes, array('13'));
            $map = self::$_issuerCodeToGiftExceptionCode;
            break;
        }

        if (in_array($responseCode, $acceptedCodes)) {
            return null;
        }

        $code = null;
        if (array_key_exists($responseCode, $map)) {
            $code = $map[$responseCode];
        }

        if ($code == null) {
            return new HpsCreditException(
                $transactionId,
                HpsExceptionCodes::UNKNOWN_CREDIT_ERROR,
                self::$_creditExceptionCodeToMessage[HpsExceptionCodes::UNKNOWN_CREDIT_ERROR],
                $responseCode,
                $responseText
            );
        }

        $message = null;
        if (array_key_exists($code, self::$_creditExceptionCodeToMessage)) {
            $message = self::$_creditExceptionCodeToMessage[$code];
        } else {
            $message = 'Unknown issuer error';
        }

        return new HpsCreditException($transactionId, $code, $message, $responseCode, $responseText);
    }
552461
public static function GetInstanceDataFromSession($sListSessionKey)
    {
        if (!array_key_exists(TdbShopArticleList::SESSIN_DUMP_NAME, $_SESSION)) {
            $_SESSION[TdbShopArticleList::SESSIN_DUMP_NAME] = array();
        }
        $aList = null;
        if (array_key_exists($sListSessionKey, $_SESSION[TdbShopArticleList::SESSIN_DUMP_NAME])) {
            $aList = $_SESSION[TdbShopArticleList::SESSIN_DUMP_NAME][$sListSessionKey];
        }

        return $aList;
    }
507938
protected function extractMessageFromErrorResponse(string $responseContents, string $fallbackMessage): string
    {
        $result = $fallbackMessage;
        try {
            $errorResponse = $this->serializer->deserialize($responseContents, ErrorResponse::class, 'json');

            if ($errorResponse instanceof ErrorResponse) {
                $result = $errorResponse->getError()->getMessage();
            }
        } catch (Exception $e) {
            // Failed to decode error response.
        }
        return $result;
    }
262881
protected function getJsonReponseFromException(Exception $ex)
    {
        $authorizationChecker = $this->get('security.authorization_checker');
        $logger = $this->get('logger');

        //can we see the debug
        $isDebugAllowed = $authorizationChecker->isGranted('ROLE_VICTOIRE_PAGE_DEBUG') ? true : $this->get('kernel')->isDebug();

        //whatever is the exception, we log it
        $logger->error($ex->getMessage());
        $logger->error($ex->getTraceAsString());

        if ($isDebugAllowed) {
            throw $ex;
        } else {
            //translate the message
            $translator = $this->get('translator');

            //get the translated message
            $message = $translator->trans('error_occured', [], 'victoire');

            $response = new JsonResponse(
                [
                    'success' => false,
                    'message' => $message,
                ]
            );
        }

        return $response;
    }