Httpful\Response::hasErrors PHP Method

hasErrors() public method

Informational 1xx Successful 2xx Redirection 3xx Client Error 4xx Server Error 5xx http://pretty-rfc.herokuapp.com/RFC2616#status.codes
public hasErrors ( ) : boolean
return boolean Did we receive a 4xx or 5xx?
    public function hasErrors()
    {
        return $this->code >= 400;
    }

Usage Example

 /**
  * Handle the response returned by the server
  *
  * Child classes could override this method to do something with the response.
  * By default this class throws an exception when the response has han error
  *
  * @param \Httpful\Response $response
  * @Param CRM_Civirules_TriggerData_TriggerData $triggerData
  * @param \Httpful\Request $request
  * @throws \Exception
  */
 protected function handleResponse(\Httpful\Response $response, \Httpful\Request $request, CRM_Civirules_TriggerData_TriggerData $triggerData)
 {
     //by default throw an error if response is not a 200 response
     if ($response->hasErrors()) {
         throw new Exception('Invalid response. Got a HTTP ' . $response->code . "\r\n\r\n" . $response->raw_headers . "\r\n\r\n" . $response->raw_body . "\r\n\r\nRequest was: " . $request->method . ': ' . $request->uri . "\r\n" . $request->raw_headers . "\r\n\r\n" . $request->payload);
     }
     //do something with the response. You could override this method in a child class to do something with the response.
 }
All Usage Examples Of Httpful\Response::hasErrors