|
|
|
|
@ -32,11 +32,11 @@ function tts_broken_error($ex = ''): void { |
|
|
|
|
\tts\api::error(array('response' => $internal_error, 'code' => 500, 'reason' => 'Internal Error')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (\main_tts\configure::get('tts', 'live') === true) { |
|
|
|
|
if (\main_tts\is_live()) { |
|
|
|
|
$resource = \main_tts\configure::get('tts', 'error_page'); |
|
|
|
|
$exists = \bs_tts\requires::secure_include('views/errors', $resource); // Show Broken Page |
|
|
|
|
if ($exists === false) { |
|
|
|
|
echo "Sorry, we had an error...We apologize for any inconvenience this may cause."; |
|
|
|
|
echo "<h1>Sorry, we had an error...</h1><p>We apologize for any inconvenience this may cause.</p>"; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$view = new \tts\view(); |
|
|
|
|
@ -211,7 +211,7 @@ function tts_json_error_handler($data) { |
|
|
|
|
} catch (Exception $e) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (\main_tts\configure::get('tts', 'live') === true) { |
|
|
|
|
if (\main_tts\is_live()) { |
|
|
|
|
\tts_email_error($data); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -251,6 +251,10 @@ function tts_json_error_handler($data) { |
|
|
|
|
* @param \Throwable $exception Error |
|
|
|
|
*/ |
|
|
|
|
function tts_exception_handler(\Throwable $exception) { |
|
|
|
|
if (!\main_tts\errors::get_handle_exceptions()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$err = "Fatal Error: Uncaught exception " . get_class($exception) . " with message: " . $exception->getMessage(); |
|
|
|
|
$err .= " thrown in: " . $exception->getFile() . " on line: " . $exception->getLine() . "\r\n"; |
|
|
|
|
$common_err = '<b>Fatal error</b>: Uncaught exception \'' . get_class($exception) . '\' with message '; |
|
|
|
|
@ -266,7 +270,7 @@ function tts_exception_handler(\Throwable $exception) { |
|
|
|
|
$msg .= $common_err; |
|
|
|
|
$msg .= '</div>'; |
|
|
|
|
|
|
|
|
|
if (\main_tts\configure::get('tts', 'live') === true) { |
|
|
|
|
if (\main_tts\is_live()) { |
|
|
|
|
tts_global_error_handler(E_USER_ERROR, $err); |
|
|
|
|
} else { |
|
|
|
|
echo tts_mini_view('dev_error', 'tts', $msg); |
|
|
|
|
@ -276,7 +280,7 @@ function tts_exception_handler(\Throwable $exception) { |
|
|
|
|
|
|
|
|
|
set_exception_handler('tts_exception_handler'); |
|
|
|
|
|
|
|
|
|
if (\main_tts\configure::get('tts', 'live') === true) { |
|
|
|
|
if (\main_tts\is_live()) { |
|
|
|
|
error_reporting(E_ALL ^ E_NOTICE); |
|
|
|
|
set_error_handler('tts_global_error_handler', E_ALL ^ (E_NOTICE | E_USER_NOTICE)); |
|
|
|
|
} else { |
|
|
|
|
@ -289,10 +293,13 @@ register_shutdown_function('tts_custom_error_checker'); |
|
|
|
|
* Custom Error Checked called on Script Shutdown. |
|
|
|
|
*/ |
|
|
|
|
function tts_custom_error_checker(): void { |
|
|
|
|
if (!\main_tts\errors::get_handle_shutdown_errors()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
$a_errors = error_get_last(); |
|
|
|
|
if (is_array($a_errors)) { |
|
|
|
|
$msg = "Error: {$a_errors['message']} File:{$a_errors['file']} Line:{$a_errors['line']}."; |
|
|
|
|
if (\main_tts\configure::get('tts', 'live') === true) { |
|
|
|
|
if (\main_tts\is_live()) { |
|
|
|
|
$msg = wordwrap($msg, WORD_WRAP_CHRS, "<br>\n"); |
|
|
|
|
try { |
|
|
|
|
$exists = \main_tts\registry::get('di')->exists('log'); |
|
|
|
|
@ -327,6 +334,10 @@ function tts_custom_error_checker(): void { |
|
|
|
|
* @param type $errline |
|
|
|
|
*/ |
|
|
|
|
function tts_global_error_handler(int $errno = 0, string $errstr = '', string $errfile = '', int $errline = 0) { |
|
|
|
|
if (!\main_tts\errors::get_handle_global_errors()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch ($errno) { |
|
|
|
|
case E_USER_ERROR: |
|
|
|
|
$err = "My ERROR [$errno] $errstr<br />\n"; |
|
|
|
|
@ -352,7 +363,7 @@ function tts_global_error_handler(int $errno = 0, string $errstr = '', string $e |
|
|
|
|
|
|
|
|
|
tts_json_error_handler($err); |
|
|
|
|
|
|
|
|
|
if (\main_tts\configure::get('tts', 'live') === false) { |
|
|
|
|
if (! \main_tts\is_live()) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|