1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-13 18:24:57 +02:00

Add WireShutdown::fatalError() hookable method to enable hooking fatal errors

This commit is contained in:
Ryan Cramer
2021-02-12 10:10:58 -05:00
parent 4406086241
commit 861d7163f6

View File

@@ -9,6 +9,8 @@
* *
* https://processwire.com * https://processwire.com
* *
* @method void fatalError(array $error)
*
*/ */
class WireShutdown extends Wire { class WireShutdown extends Wire {
@@ -471,6 +473,15 @@ class WireShutdown extends Wire {
return $out === $token ? false : true; return $out === $token ? false : true;
} }
/**
* Hook called when fatal error received by shutdown()
*
* @param array $error
* @since 3.0.173
*
*/
protected function ___fatalError($error) { }
/** /**
* Shutdown function registered with PHP * Shutdown function registered with PHP
* *
@@ -484,6 +495,7 @@ class WireShutdown extends Wire {
if(!$error) return true; if(!$error) return true;
if(!in_array($error['type'], $this->fatalTypes)) return true; if(!in_array($error['type'], $this->fatalTypes)) return true;
if(empty($this->error)) $this->fatalError($error);
$this->error = $error; $this->error = $error;
$this->prepareLabels(); $this->prepareLabels();
$config = $this->config; $config = $this->config;