aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/XMLRPCErrorResponse.php
blob: c3dbd0373a2879169bf1fbf254f948764800c74f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

/**
 * XMLRPC Error Response
 *
 * @package    Elgg.Core
 * @subpackage XMLRPC
 */
class XMLRPCErrorResponse extends XMLRPCResponse {
	/**
	 * Set the error response and error code.
	 *
	 * @param string $message The message
	 * @param int    $code    Error code (default = system error as defined by
	 *                        http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php)
	 */
	function __construct($message, $code = -32400) {
		$this->addParameter(
			new XMLRPCStructParameter(
				array (
					'faultCode' => new XMLRPCIntParameter($code),
					'faultString' => new XMLRPCStringParameter($message)
				)
			)
		);
	}

	/**
	 * Output to XML.
	 *
	 * @return string
	 */
	public function __toString() {
		return "<methodResponse><fault><value>{$this->parameters[0]}</value></fault></methodResponse>";
	}
}