[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of JSON-API. 5 * 6 * (c) Toby Zerner <[email protected]> 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 Tobscure\JsonApi\Exception\Handler; 13 14 use Exception; 15 16 class FallbackExceptionHandler implements ExceptionHandlerInterface 17 { 18 /** 19 * @var bool 20 */ 21 private $debug; 22 23 /** 24 * @param bool $debug 25 */ 26 public function __construct($debug) 27 { 28 $this->debug = $debug; 29 } 30 31 /** 32 * {@inheritdoc} 33 */ 34 public function manages(Exception $e) 35 { 36 return true; 37 } 38 39 /** 40 * {@inheritdoc} 41 */ 42 public function handle(Exception $e) 43 { 44 $status = 500; 45 $error = $this->constructError($e, $status); 46 47 return new ResponseBag($status, [$error]); 48 } 49 50 /** 51 * @param \Exception $e 52 * @param $status 53 * 54 * @return array 55 */ 56 private function constructError(Exception $e, $status) 57 { 58 $error = ['code' => $status, 'title' => 'Internal server error']; 59 60 if ($this->debug) { 61 $error['detail'] = (string) $e; 62 } 63 64 return $error; 65 } 66 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |