1 <?php
2 /* --------------------------------------------------------------
3 AjaxException.php 2015-03-12 gm
4 Gambio GmbH
5 http://www.gambio.de
6 Copyright (c) 2015 Gambio GmbH
7 Released under the GNU General Public License (Version 2)
8 [http://www.gnu.org/licenses/gpl-2.0.html]
9 --------------------------------------------------------------
10 */
11
12 /**
13 * Class AjaxException
14 *
15 * @category System
16 * @package Http
17 * @subpackage Exceptions
18 * @extends Exception
19 */
20 class AjaxException extends Exception
21 {
22 /**
23 * Returns a JSON encoded object containing the exception information.
24 *
25 * This particular exception class can pass JSON encoded information as an
26 * AJAX response, so that they can be parsed and manipulated by JavaScript.
27 *
28 * @param Exception $ex Contains the exception information to be returned as a response.
29 *
30 * @return array Provide this array as an argument in the JsonHttpControllerResponse object.
31 */
32 public static function response(Exception $ex)
33 {
34 return array(
35 'exception' => true,
36 'message' => $ex->getMessage(),
37 'code' => $ex->getCode(),
38 'file' => $ex->getFile(),
39 'line' => $ex->getLine(),
40 'trace' => $ex->getTrace(),
41 'previous' => $ex->getPrevious(),
42 'traceAsString' => $ex->getTraceAsString()
43 );
44 }
45 }