ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
FacebookApiException Class Reference

Copyright 2011 Facebook, Inc. More...

+ Inheritance diagram for FacebookApiException:
+ Collaboration diagram for FacebookApiException:

Public Member Functions

 __construct ($result)
 Make a new API Exception with the given result. More...
 
 getResult ()
 Return the associated result object returned by the API server. More...
 
 getType ()
 Returns the associated type for the error. More...
 
 __toString ()
 To make debugging easier. More...
 

Protected Attributes

 $result
 The result from the API server that represents the exception information. More...
 

Detailed Description

Copyright 2011 Facebook, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Thrown when an API call returns an exception.

Author
Naitik Shah naiti.nosp@m.k@fa.nosp@m.ceboo.nosp@m.k.co.nosp@m.m

Definition at line 30 of file base_facebook.php.

Constructor & Destructor Documentation

◆ __construct()

FacebookApiException::__construct (   $result)

Make a new API Exception with the given result.

Parameters
array$resultThe result from the API server

Definition at line 42 of file base_facebook.php.

References $code, and $result.

42  {
43  $this->result = $result;
44 
45  $code = isset($result['error_code']) ? $result['error_code'] : 0;
46 
47  if (isset($result['error_description'])) {
48  // OAuth 2.0 Draft 10 style
49  $msg = $result['error_description'];
50  } else if (isset($result['error']) && is_array($result['error'])) {
51  // OAuth 2.0 Draft 00 style
52  $msg = $result['error']['message'];
53  } else if (isset($result['error_msg'])) {
54  // Rest server style
55  $msg = $result['error_msg'];
56  } else {
57  $msg = 'Unknown Error. Check getResult()';
58  }
59 
60  parent::__construct($msg, $code);
61  }
$code
Definition: example_050.php:99
$result
The result from the API server that represents the exception information.

Member Function Documentation

◆ __toString()

FacebookApiException::__toString ( )

To make debugging easier.

Returns
string The string representation of the error

Definition at line 100 of file base_facebook.php.

References $message, and getType().

100  {
101  $str = $this->getType() . ': ';
102  if ($this->code != 0) {
103  $str .= $this->code . ': ';
104  }
105  return $str . $this->message;
106  }
getType()
Returns the associated type for the error.
catch(Exception $e) $message
+ Here is the call graph for this function:

◆ getResult()

FacebookApiException::getResult ( )

Return the associated result object returned by the API server.

Returns
array The result from the API server

Definition at line 68 of file base_facebook.php.

References $result.

68  {
69  return $this->result;
70  }
$result
The result from the API server that represents the exception information.

◆ getType()

FacebookApiException::getType ( )

Returns the associated type for the error.

This will default to 'Exception' when a type is not available.

Returns
string

Definition at line 78 of file base_facebook.php.

References $error.

Referenced by __toString().

78  {
79  if (isset($this->result['error'])) {
80  $error = $this->result['error'];
81  if (is_string($error)) {
82  // OAuth 2.0 Draft 10 style
83  return $error;
84  } else if (is_array($error)) {
85  // OAuth 2.0 Draft 00 style
86  if (isset($error['type'])) {
87  return $error['type'];
88  }
89  }
90  }
91 
92  return 'Exception';
93  }
$error
Definition: Error.php:17
+ Here is the caller graph for this function:

Field Documentation

◆ $result

FacebookApiException::$result
protected

The result from the API server that represents the exception information.

Definition at line 35 of file base_facebook.php.

Referenced by __construct(), BaseFacebook\_graph(), BaseFacebook\_restserver(), getResult(), BaseFacebook\makeRequest(), and BaseFacebook\throwAPIException().


The documentation for this class was generated from the following file: