XRL  2.0.0
Simple XML-RPC Library (both client and server)
Faults.php
1 <?php
2 /*
3  * This file is part of XRL, a simple XML-RPC Library for PHP.
4  *
5  * Copyright (c) 2012, XRL Team. All rights reserved.
6  * XRL is licensed under the 3-clause BSD License.
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace fpoirotte\XRL;
13 
21 class Faults
22 {
24  protected static $faults = array(
25  'NOT_WELL_FORMED' => array(
26  'code' => -32700,
27  'msg' => 'parse error. not well formed',
28  ),
29  'UNSUPPORTED_ENCODING' => array(
30  'code' => -32701,
31  'msg' => 'parse error. unsupported encoding',
32  ),
33  'INVALID_CHARACTER' => array(
34  'code' => -32702,
35  'msg' => 'parse error. invalid character for encoding',
36  ),
37  'INVALID_XML_RPC' => array(
38  'code' => -32600,
39  'msg' => 'server error. invalid xml-rpc. not conforming to spec',
40  ),
41  'METHOD_NOT_FOUND' => array(
42  'code' => -32601,
43  'msg' => 'server error. requested method not found',
44  ),
45  'INVALID_PARAMETERS' => array(
46  'code' => -32602,
47  'msg' => 'server error. invalid method parameters',
48  ),
49  'INTERNAL_ERROR' => array(
50  'code' => -32603,
51  'msg' => 'server error. internal xml-rpc error',
52  ),
53  'APPLICATION_ERROR' => array(
54  'code' => -32500,
55  'msg' => 'application error',
56  ),
57  'SYSTEM_ERROR' => array(
58  'code' => -32400,
59  'msg' => 'system error',
60  ),
61  'TRANSPORT_ERROR' => array(
62  'code' => -32300,
63  'msg' => 'transport error',
64  ),
65  );
66 
68  const NOT_WELL_FORMED = 'NOT_WELL_FORMED';
69 
71  const UNSUPPORTED_ENCODING = 'UNSUPPORTED_ENCODING';
72 
74  const INVALID_CHARACTER = 'INVALID_CHARACTER';
75 
77  const INVALID_XML_RPC = 'INVALID_XML_RPC';
78 
80  const METHOD_NOT_FOUND = 'METHOD_NOT_FOUND';
81 
83  const INVALID_PARAMETERS = 'INVALID_PARAMETERS';
84 
86  const INTERNAL_ERROR = 'INTERNAL_ERROR';
87 
89  const APPLICATION_ERROR = 'APPLICATION_ERROR';
90 
92  const SYSTEM_ERROR = 'SYSTEM_ERROR';
93 
95  const TRANSPORT_ERROR = 'TRANSPORT_ERROR';
96 
97 
102  final private function __construct()
103  {
104  }
105 
125  public static function get($fault, \Exception $exc = null)
126  {
127  if (!isset(self::$faults[$fault])) {
128  throw new \InvalidArgumentException('Unknown interoperability fault');
129  }
130  $params = self::$faults[$fault];
131  return new \fpoirotte\XRL\Exception($params['msg'], $params['code'], $exc);
132  }
133 }
Definitions of interoperability faults.
Definition: Faults.php:21
static $faults
Parameters for interoperability faults.
Definition: Faults.php:24
An exception that is used to represent XML-RPC errors.
Definition: Exception.php:21
const APPLICATION_ERROR
Alias for the corresponding interoperability fault.
Definition: Faults.php:89
const TRANSPORT_ERROR
Alias for the corresponding interoperability fault.
Definition: Faults.php:95
const UNSUPPORTED_ENCODING
Alias for the corresponding interoperability fault.
Definition: Faults.php:71
const INVALID_CHARACTER
Alias for the corresponding interoperability fault.
Definition: Faults.php:74
const INVALID_PARAMETERS
Alias for the corresponding interoperability fault.
Definition: Faults.php:83
const INVALID_XML_RPC
Alias for the corresponding interoperability fault.
Definition: Faults.php:77
const INTERNAL_ERROR
Alias for the corresponding interoperability fault.
Definition: Faults.php:86
const NOT_WELL_FORMED
Alias for the corresponding interoperability fault.
Definition: Faults.php:68
const METHOD_NOT_FOUND
Alias for the corresponding interoperability fault.
Definition: Faults.php:80
const SYSTEM_ERROR
Alias for the corresponding interoperability fault.
Definition: Faults.php:92