diff --git a/src/Indatus/ActiveResource/ActiveResource.php b/src/Indatus/ActiveResource/ActiveResource.php index 48ef8b6..cb9f203 100644 --- a/src/Indatus/ActiveResource/ActiveResource.php +++ b/src/Indatus/ActiveResource/ActiveResource.php @@ -949,15 +949,20 @@ public static function find($id, $getParams = array()) //handle error saving $request->getEventDispatcher()->addListener( 'request.error', - function (\Guzzle\Common\Event $event) { - + //instance must be passed by reference since it's in a call back + function (\Guzzle\Common\Event $event) use (&$instance) { if ($event['response']->getStatusCode() == 404) { - // Stop other events from firing $event->stopPropagation(); //not found $instance = false; + + } else if($event['response']->getStatusCode() == 500) { + + $event->stopPropagation(); + //not found + $instance = false; } } ); @@ -971,7 +976,7 @@ function (\Guzzle\Common\Event $event) { //send the request $response = self::sendRequest($request); - + if ($response->getStatusCode() == 404 || $instance === false) { return null; }