protected function findExceptions($response)
    {
        $response = $response['body'];

        $data = json_decode($response, true);

        if (isset($response[0]) && $response[0] !== '{' && $response[0] !== '[' && !$data) {
            if (strpos($response, 'oauth_token=') !== false) {
                parse_str($response, $data);
            }

            if (empty($data) || !is_array($data)) {
                throw new TwitterException($response, 0);
            }

            return json_encode($data);
        }

        if (!empty($data['errors']) || !empty($data['error'])) {
            if (!empty($data['errors'])) {
                $data = current($data['errors']);
            }

            if (empty($data['message']) && !empty($data['error'])) {
                $data['message'] = $data['error'];
            }

            if (!isset($data['code']) || empty($data['code'])) {
                $data['code'] = 0;
            }

            throw new TwitterException($data['message'], $data['code']);
        }

        unset($data);

        return $response;
    }
protected function findExceptions($response)
    {
        $response = $response['body'];

        $data = json_decode($response, true);

        if (isset($response[0]) && $response[0] !== '{' && $response[0] !== '[' && !$data) {
            if (strpos($response, 'oauth_token=') !== false) {
                parse_str($response, $data);
            }

            if (empty($data) || !is_array($data)) {
                throw new TwitterException($response, 0);
            }

            return json_encode($data);
        }

        if (!empty($data['errors']) || !empty($data['error'])) {
            if (!empty($data['errors'])) {
                $data = current($data['errors']);
            }

            if (empty($data['message']) && !empty($data['error'])) {
                $data['message'] = $data['error'];
            }

            if (!isset($data['code']) || empty($data['code'])) {
                $data['code'] = 0;
            }

            throw new TwitterException($data['message'], $data['code']);
        }

        unset($data);

        return $response;
    }
protected function findExceptions ( $ response ) { $ response = $ response [ 'body' ] ; $ data = json_decode ( $ response , true ) ; if ( isset ( $ response [ 0 ] ) && $ response [ 0 ] !== '{' && $ response [ 0 ] !== '[' && ! $ data ) { if ( strpos ( $ response , 'oauth_token=' ) !== false ) { parse_str ( $ response , $ data ) ; } if ( empty ( $ data ) || ! is_array ( $ data ) ) { throw new TwitterException ( $ response , 0 ) ; } return json_encode ( $ data ) ; } if ( ! empty ( $ data [ 'errors' ] ) || ! empty ( $ data [ 'error' ] ) ) { if ( ! empty ( $ data [ 'errors' ] ) ) { $ data = current ( $ data [ 'errors' ] ) ; } if ( empty ( $ data [ 'message' ] ) && ! empty ( $ data [ 'error' ] ) ) { $ data [ 'message' ] = $ data [ 'error' ] ; } if ( ! isset ( $ data [ 'code' ] ) || empty ( $ data [ 'code' ] ) ) { $ data [ 'code' ] = 0 ; } throw new TwitterException ( $ data [ 'message' ] , $ data [ 'code' ] ) ; } unset ( $ data ) ; return $ response ; }
Processing Twitter Exceptions in case of error

@param array $response Raw response
@return string
@throws TwitterException
Processing Twitter Exceptions in case of error