Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 class OAuth2Exception extends Exception {
00012
00013
00014
00015
00016 protected $result;
00017
00018
00019
00020
00021
00022
00023
00024 public function __construct($result) {
00025 $this->result = $result;
00026
00027 $code = isset($result['code']) ? $result['code'] : 0;
00028
00029 if (isset($result['error'])) {
00030
00031 $message = $result['error'];
00032 }
00033 elseif (isset($result['message'])) {
00034
00035 $message = $result['message'];
00036 }
00037 else {
00038 $message = 'Unknown Error. Check getResult()';
00039 }
00040
00041 parent::__construct($message, $code);
00042 }
00043
00044
00045
00046
00047
00048
00049
00050 public function getResult() {
00051 return $this->result;
00052 }
00053
00054
00055
00056
00057
00058
00059
00060
00061 public function getType() {
00062 if (isset($this->result['error'])) {
00063 $message = $this->result['error'];
00064 if (is_string($message)) {
00065
00066 return $message;
00067 }
00068 }
00069 return 'Exception';
00070 }
00071
00072
00073
00074
00075
00076
00077
00078 public function __toString() {
00079 $str = $this->getType() . ': ';
00080 if ($this->code != 0) {
00081 $str .= $this->code . ': ';
00082 }
00083 return $str . $this->message;
00084 }
00085 }