3 * This file is part of libomb
7 * LICENSE: This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * @author Adrian Lang <mail@adrianlang.de>
22 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
23 * @version 0.1a-20090828
24 * @link http://adrianlang.de/libomb
28 * Exception stating that the remote service had a failure
30 * This exception is raised when a remote service failed to return a valid
31 * response to a request or send a valid request.
33 class OMB_RemoteServiceException extends Exception
36 * Create exception from Yadis response
38 * Creates an exception from a passed yadis result.
40 * @param string $request_uri The target URI for the failed
42 * @param Auth_Yadis_HTTPResponse $result The result of the failed
45 * @return OMB_RemoteServiceException A new exception
47 public static function fromYadis($request_uri, $result)
49 if ($result->status == 200) {
50 $err = 'Got wrong response ' . $result->body;
52 $err = 'Got error code ' . $result->status . ' with response ' .
55 return OMB_RemoteServiceException::forRequest($request_uri, $err);
59 * Create exception for a call to a resource
61 * Creates an exception for a given error message and target URI.
63 * @param string $action_uri The target URI for the failed request
64 * @param string $failure An error message
66 * @return OMB_RemoteServiceException A new exception
68 public static function forRequest($action_uri, $failure)
70 return new OMB_RemoteServiceException("Handler for $action_uri: $failure");