3 * Exception stating that the remote service had a failure
5 * This exception is raised when a remote service failed to return a valid
6 * response to a request or send a valid request.
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.
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.
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/>.
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
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;
33 $err = 'Got error code ' . $result->status . ' with response ' . $result->body;
35 return new OMB_RemoteServiceException($request_uri . ': ' . $err);
38 public static function forRequest($action_uri, $failure) {
39 return new OMB_RemoteServiceException("Handler for $action_uri: " . $failure);