|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Main exceptions file. |
|
4
|
|
|
* |
|
5
|
|
|
* @package App |
|
6
|
|
|
* |
|
7
|
|
|
* @see http://php.net/manual/en/class.exception.php |
|
8
|
|
|
* |
|
9
|
|
|
* @copyright YetiForce Sp. z o.o. |
|
10
|
|
|
* @license YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com) |
|
11
|
|
|
* @author Mariusz Krzaczkowski <[email protected]> |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace App\Exceptions; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Main exceptions class. |
|
18
|
|
|
*/ |
|
19
|
|
|
class AppException extends \Exception |
|
20
|
|
|
{ |
|
21
|
|
|
/** @var string Default error exception template. */ |
|
22
|
|
|
public $tplName = 'Exception.tpl'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Construct the exception. |
|
26
|
|
|
* |
|
27
|
|
|
* @param string $message |
|
28
|
|
|
* @param int $code |
|
29
|
|
|
* @param \Throwable $previous |
|
|
|
|
|
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct($message, $code = 200, \Throwable $previous = null) |
|
32
|
|
|
{ |
|
33
|
|
|
parent::__construct($message, $code, $previous); |
|
34
|
|
|
$this->backtrace = \App\Debug::getBacktrace(); |
|
|
|
|
|
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Show view. |
|
39
|
|
|
* |
|
40
|
|
|
* @param \Throwable $e |
|
41
|
|
|
* |
|
42
|
|
|
* @return void |
|
43
|
|
|
*/ |
|
44
|
|
|
public static function view(\Throwable $e): void |
|
45
|
|
|
{ |
|
46
|
|
|
$viewer = new \App\Viewer(); |
|
47
|
|
|
if (\App\Config::get('displayDetailsException')) { |
|
48
|
|
|
$viewer->assign('MESSAGE', $e->getMessage()); |
|
49
|
|
|
$viewer->assign('BACKTRACE', empty($e->backtrace) ? $e->getTraceAsString() : $e->backtrace); |
|
|
|
|
|
|
50
|
|
|
$viewer->assign('SESSION', $_SESSION); |
|
51
|
|
|
} |
|
52
|
|
|
$viewer->assign('CODE', $e->getCode()); |
|
53
|
|
|
$viewer->assign('CSS_FILE', [ |
|
54
|
|
|
PUBLIC_DIRECTORY . 'libraries/@fortawesome/fontawesome-free/css/all.css', |
|
55
|
|
|
PUBLIC_DIRECTORY . 'libraries/@mdi/font/css/materialdesignicons.css', |
|
56
|
|
|
PUBLIC_DIRECTORY . 'libraries/bootstrap/dist/css/bootstrap.css', |
|
57
|
|
|
PUBLIC_DIRECTORY . 'layouts/' . \App\Viewer::getLayoutName() . '/skins/basic/Main.css', |
|
58
|
|
|
]); |
|
59
|
|
|
$viewer->view($e->tplName); |
|
|
|
|
|
|
60
|
|
|
if (\App\Config::$debugApi && \App\Session::has('debugApi') && \App\Session::get('debugApi')) { |
|
61
|
|
|
$viewer->assign('DEBUG_API', \App\Session::get('debugApi')); |
|
62
|
|
|
$viewer->assign('COLLAPSE', true); |
|
63
|
|
|
$viewer->view('DebugApi.tpl'); |
|
64
|
|
|
\App\Session::set('debugApi', false); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.