You are here

function PEAR::isError in Flickr API 5

Tell whether a value is a PEAR error.

@access public

Parameters

mixed $data the value to test:

int $code if $data is an error object, return true: only if $code is a string and $obj->getMessage() == $code or $code is an integer and $obj->getCode() == $code

Return value

bool true if parameter is an error

2 calls to PEAR::isError()
HTTP_Request::sendRequest in phpFlickr/PEAR/HTTP/Request.php
Sends the request
HTTP_Response::process in phpFlickr/PEAR/HTTP/Request.php
Processes a HTTP response

File

phpFlickr/PEAR/PEAR.php, line 278

Class

PEAR
Base class for other PEAR classes. Provides rudimentary emulation of destructors.

Code

function isError($data, $code = null) {
  if (is_a($data, 'PEAR_Error')) {
    if (is_null($code)) {
      return true;
    }
    elseif (is_string($code)) {
      return $data
        ->getMessage() == $code;
    }
    else {
      return $data
        ->getCode() == $code;
    }
  }
  return false;
}