1 | <?php |
||
19 | trait ErrorHandlerTrait |
||
20 | { |
||
21 | /** |
||
22 | * @var string The url of the error api without trailing slash. Make sure you have installed the error api |
||
23 | * module on the requested api url (https://luya.io/guide/module/luyadev---luya-module-errorapi). |
||
24 | * |
||
25 | * An example when using the erroapi module, the url could look like this `https://luya.io/errorapi`. |
||
26 | */ |
||
27 | public $api; |
||
28 | |||
29 | /** |
||
30 | * @var boolean Enable the transfer of exceptions to the defined `$api` server. |
||
31 | */ |
||
32 | public $transferException = false; |
||
33 | |||
34 | /** |
||
35 | * @var \Curl\Curl|null The curl object from the last error api call. |
||
36 | * @since 1.0.5 |
||
37 | */ |
||
38 | public $lastTransferCall; |
||
39 | |||
40 | /** |
||
41 | * @var array An array of exceptions which are whitelisted and therefore NOT TRANSFERED. |
||
42 | * @since 1.0.5 |
||
43 | */ |
||
44 | public $whitelist = ['yii\web\NotFoundHttpException']; |
||
45 | |||
46 | /** |
||
47 | * @var array |
||
48 | * @since 1.0.6 |
||
49 | */ |
||
50 | public $sensitiveKeys = ['password', 'pwd', 'pass', 'passwort', 'pw', 'token', 'hash', 'authorization']; |
||
51 | |||
52 | /** |
||
53 | * Send a custom message to the api server event its not related to an exception. |
||
54 | * |
||
55 | * Sometimes you just want to pass informations from your application, this method allows you to transfer |
||
56 | * a message to the error api server. |
||
57 | * |
||
58 | * Example of sending a message |
||
59 | * |
||
60 | * ```php |
||
61 | * Yii::$app->errorHandler->transferMessage('Something went wrong here!', __FILE__, __LINE__); |
||
62 | * ``` |
||
63 | * |
||
64 | * @param string $message The message you want to send to the error api server. |
||
65 | * @param string $file The you are currently send the message (use __FILE__) |
||
66 | * @param string $line The line you want to submit (use __LINE__) |
||
67 | * @return bool|null |
||
68 | */ |
||
69 | public function transferMessage($message, $file = __FILE__, $line = __LINE__) |
||
77 | |||
78 | /** |
||
79 | * Send the array data to the api server. |
||
80 | * |
||
81 | * @param array $data The array to be sent to the server. |
||
82 | * @return boolean|null true/false if data has been sent to the api successfull or not, null if the transfer is disabled. |
||
83 | */ |
||
84 | private function apiServerSendData(array $data) |
||
101 | |||
102 | /** |
||
103 | * @inheritdoc |
||
104 | */ |
||
105 | public function renderException($exception) |
||
113 | |||
114 | /** |
||
115 | * Get an readable array to transfer from an exception |
||
116 | * |
||
117 | * @param mixed $exception Exception object |
||
118 | * @return array An array with transformed exception data |
||
119 | */ |
||
120 | public function getExceptionArray($exception) |
||
170 | |||
171 | /** |
||
172 | * Build trace array from exception. |
||
173 | * |
||
174 | * @param object $exception |
||
175 | * @return array |
||
176 | */ |
||
177 | private function buildTrace($exception) |
||
191 | } |
||
192 |