src/Exceptions/TelegramResponseException.php
public static function create(TelegramResponse $response)
    {
        $data = $response->getDecodedBody();

        $code = null;
        $message = null;
        if (isset($data['ok'], $data['error_code']) && $data['ok'] === false) {
            $code = $data['error_code'];
            $message = isset($data['description']) ? $data['description'] : 'Unknown error from API.';
        }

        // Others
        throw new static($response, new TelegramOtherException($message, $code));
    }
public static function create(TelegramResponse $response)
    {
        $data = $response->getDecodedBody();

        $code = null;
        $message = null;
        if (isset($data['ok'], $data['error_code']) && $data['ok'] === false) {
            $code = $data['error_code'];
            $message = isset($data['description']) ? $data['description'] : 'Unknown error from API.';
        }

        // Others
        throw new static($response, new TelegramOtherException($message, $code));
    }
public static function create ( TelegramResponse $ response ) { $ data = $ response -> getDecodedBody ( ) ; $ code = null ; $ message = null ; if ( isset ( $ data [ 'ok' ] , $ data [ 'error_code' ] ) && $ data [ 'ok' ] === false ) { $ code = $ data [ 'error_code' ] ; $ message = isset ( $ data [ 'description' ] ) ? $ data [ 'description' ] : 'Unknown error from API.' ; } // Others throw new static ( $ response , new TelegramOtherException ( $ message , $ code ) ) ; }
A factory for creating the appropriate exception based on the response from Telegram.

@param TelegramResponse $response The response that threw the exception.

@return TelegramResponseException
A factory for creating the appropriate exception based on the response from Telegram .