error() публичный Метод

Error
public error ( $callback )
$callback
Пример #1
0
 /**
  * [getValidation description]
  * @param  Request $request
  * @return [type]
  */
 protected function getValidation(Request $request)
 {
     $client = $this;
     $curl = new Curl();
     $curl->success(function ($instance) use($client) {
         $client->response = new Crawler();
         $client->response->addXmlContent($instance->response);
     });
     $curl->error(function ($instance) {
         throw new CasCurlException(sprintf('Code #%s: %s', $instance->error_code, $instance->error_message));
     });
     $curl->get($this->getValidationUrl($request));
 }
Пример #2
0
 /**
  * Make a request
  * @param string $route the route to call
  * @return Curl
  * @throws ApiException
  */
 protected static function request($route = '')
 {
     $accessToken = self::getAccessToken();
     $curl = new Curl();
     $curl->base_url = $accessToken->url . ($route != '' ? $route : '');
     $curl->setHeader('Authorization', $accessToken->token);
     $curl->complete(function () use($curl) {
         $curl->close();
     });
     $curl->error(function () use($curl) {
         $message = is_object($curl->response) ? $curl->response->message : $curl->error_message;
         throw new ApiException($message);
     });
     return $curl;
 }