]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - extlib/libomb/remoteserviceexception.php
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
[quix0rs-gnu-social.git] / extlib / libomb / remoteserviceexception.php
1 <?php
2 /**
3  * Exception stating that the remote service had a failure
4  *
5  * This exception is raised when a remote service failed to return a valid
6  * response to a request or send a valid request.
7  *
8  * PHP version 5
9  *
10  * LICENSE: This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  * @package   OMB
24  * @author    Adrian Lang <mail@adrianlang.de>
25  * @copyright 2009 Adrian Lang
26  * @license   http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
27  **/
28 class OMB_RemoteServiceException extends Exception {
29   public static function fromYadis($request_uri, $result) {
30     if ($result->status == 200) {
31         $err = 'Got wrong response ' . $result->body;
32     } else {
33         $err = 'Got error code ' . $result->status . ' with response ' . $result->body;
34     }
35     return new OMB_RemoteServiceException($request_uri . ': ' .  $err);
36   }
37
38   public static function forRequest($action_uri, $failure) {
39     return new OMB_RemoteServiceException("Handler for $action_uri: " .  $failure);
40   }
41 }
42 ?>