object(stdClass)#202错误

I'm getting the error:

object(stdClass)#202 (1) {
   ["errors"]=> array(1) {
      [0]=> object(stdClass)#201 (2) {
         ["message"]=> string(31) "Sorry, that page does not exist" ["code"]=> int(34) 
      }
   } 
}

Normally an array would be returned.

I know what is causing the error, I would just like to check if an error occurs before proceeding.

What's the best way to check?

I've tried a try/catch, does not catch the error.

I've tried an is_array, which works. But is there a better way?

Also how can I access the 'errors' key in the error above?

You can access it via

$obj->errors; //Or whatever your stdClass variable is.

Maybe do something like,

if($obj->errors){ //isset() might be better?
    foreach($obj->errors as $error){
        echo "Error(".$error->code.") ".$error->message;
    }
}