src/iMoneza/Connection.php
protected function handleRequestError($result)
    {
        /**
         * Curl error
         */
        if ($result === false) {
            throw new Exception\TransferError($this->request->getErrorString(), $this->request->getErrorCode());
        }

        switch ($this->request->getResponseHTTPCode()) {
            case 401:
                $this->error($result, ['CODE'=>401]);
                throw new Exception\AuthenticationFailure($result, 401);
                break;
            case 403:
                $this->error($result, ['CODE'=>403]);
                throw new Exception\AccessDenied($result, 403);
                break;
            case 404:
                //sometimes it's a json string, sometimes it's not... so there's that.
                if (stripos($result, '{') === 0) {
                    $error = json_decode($result);
                    $errorMessage = $error->Message;
                }
                else {
                    $errorMessage = $result;
                }
                $this->error($errorMessage, ['CODE'=>404]);
                throw new Exception\NotFound($errorMessage, 404);
                break;
        }
    }
protected function handleRequestError($result)
    {
        /**
         * Curl error
         */
        if ($result === false) {
            throw new Exception\TransferError($this->request->getErrorString(), $this->request->getErrorCode());
        }

        switch ($this->request->getResponseHTTPCode()) {
            case 401:
                $this->error($result, ['CODE'=>401]);
                throw new Exception\AuthenticationFailure($result, 401);
                break;
            case 403:
                $this->error($result, ['CODE'=>403]);
                throw new Exception\AccessDenied($result, 403);
                break;
            case 404:
                //sometimes it's a json string, sometimes it's not... so there's that.
                if (stripos($result, '{') === 0) {
                    $error = json_decode($result);
                    $errorMessage = $error->Message;
                }
                else {
                    $errorMessage = $result;
                }
                $this->error($errorMessage, ['CODE'=>404]);
                throw new Exception\NotFound($errorMessage, 404);
                break;
        }
    }
protected function handleRequestError ( $ result ) { /**
         * Curl error
         */ if ( $ result === false ) { throw new Exception \ TransferError ( $ this -> request -> getErrorString ( ) , $ this -> request -> getErrorCode ( ) ) ; } switch ( $ this -> request -> getResponseHTTPCode ( ) ) { case 401 : $ this -> error ( $ result , [ 'CODE' => 401 ] ) ; throw new Exception \ AuthenticationFailure ( $ result , 401 ) ; break ; case 403 : $ this -> error ( $ result , [ 'CODE' => 403 ] ) ; throw new Exception \ AccessDenied ( $ result , 403 ) ; break ; case 404 : //sometimes it's a json string, sometimes it's not... so there's that. if ( stripos ( $ result , '{' ) === 0 ) { $ error = json_decode ( $ result ) ; $ errorMessage = $ error -> Message ; } else { $ errorMessage = $ result ; } $ this -> error ( $ errorMessage , [ 'CODE' => 404 ] ) ; throw new Exception \ NotFound ( $ errorMessage , 404 ) ; break ; } }
Handles a potential request error by throwing a useful exception
@param $result string|false
@throws Exception\AccessDenied
@throws Exception\AuthenticationFailure
@throws Exception\NotFound
@throws Exception\TransferError
Handles a potential request error by throwing a useful exception