1
0
mirror of https://github.com/beestat/app.git synced 2025-06-03 05:36:51 -04:00

Cleaned up Sentry reporting a bit.

Sometimes it would get called twice and some variables were being set too late.
This commit is contained in:
Jon Ziebell 2020-06-23 07:48:22 -04:00
parent 2e2de518e5
commit 474f4476fc

View File

@ -424,20 +424,25 @@ final class request {
* @return string The JSON response with the error details. * @return string The JSON response with the error details.
*/ */
public function error_handler($error_code, $error_message, $error_file, $error_line) { public function error_handler($error_code, $error_message, $error_file, $error_line) {
$this->error_detail['file'] = $error_file;
$this->error_detail['line'] = $error_line;
$this->error_detail['trace'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$this->error_detail['extra'] = null;
$this->set_error_response( $this->set_error_response(
$error_message, $error_message,
$error_code, $error_code,
true true
); );
$this->error_detail['file'] = $error_file;
$this->error_detail['line'] = $error_line;
$this->error_detail['trace'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
try { try {
$database = database::get_instance(); $database = database::get_instance();
$this->error_detail['queries'] = $database->get_queries(); $this->error_detail['queries'] = $database->get_queries();
} catch(Exception $e) {} } catch(Exception $e) {}
// Since we've caught the error, anything left here can be cleared.
error_clear_last();
die(); // Do not continue execution; shutdown handler will now run. die(); // Do not continue execution; shutdown handler will now run.
} }
@ -448,21 +453,25 @@ final class request {
* @param Exception $e The exception. * @param Exception $e The exception.
*/ */
public function exception_handler($e) { public function exception_handler($e) {
$this->error_detail['file'] = $e->getFile();
$this->error_detail['line'] = $e->getLine();
$this->error_detail['trace'] = $e->getTrace();
$this->error_detail['extra'] = (method_exists($e, 'getExtraInfo') === true ? $e->getExtraInfo() : null);
$this->set_error_response( $this->set_error_response(
$e->getMessage(), $e->getMessage(),
$e->getCode(), $e->getCode(),
(method_exists($e, 'getReportable') === true ? $e->getReportable() : true) (method_exists($e, 'getReportable') === true ? $e->getReportable() : true)
); );
$this->error_detail['file'] = $e->getFile();
$this->error_detail['line'] = $e->getLine();
$this->error_detail['trace'] = $e->getTrace();
$this->error_detail['extra'] = (method_exists($e, 'getExtraInfo') === true ? $e->getExtraInfo() : null);
try { try {
$database = database::get_instance(); $database = database::get_instance();
$this->error_detail['queries'] = $database->get_queries(); $this->error_detail['queries'] = $database->get_queries();
} catch(Exception $e) {} } catch(Exception $e) {}
// Since we've caught the error, anything left here can be cleared.
error_clear_last();
die(); // Do not continue execution; shutdown handler will now run. die(); // Do not continue execution; shutdown handler will now run.
} }
@ -580,15 +589,18 @@ final class request {
// will catch fatal errors that I can't. // will catch fatal errors that I can't.
$error = error_get_last(); $error = error_get_last();
if($error !== null) { if($error !== null) {
$this->error_detail['file'] = $error['file'];
$this->error_detail['line'] = $error['line'];
$this->error_detail['trace'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$this->error_detail['extra'] = null;
$this->set_error_response( $this->set_error_response(
$error['message'], $error['message'],
$error['type'], $error['type'],
true true
); );
$this->error_detail['file'] = $error['file'];
$this->error_detail['line'] = $error['line'];
$this->error_detail['trace'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
try { try {
$database = database::get_instance(); $database = database::get_instance();
$this->error_detail['queries'] = $database->get_queries(); $this->error_detail['queries'] = $database->get_queries();
@ -634,16 +646,17 @@ final class request {
} }
} }
catch(\Exception $e) { catch(\Exception $e) {
$this->error_detail['file'] = $e->getFile();
$this->error_detail['line'] = $e->getLine();
$this->error_detail['trace'] = $e->getTrace();
$this->error_detail['extra'] = (method_exists($e, 'getExtraInfo') === true ? $e->getExtraInfo() : null);
$this->set_error_response( $this->set_error_response(
$e->getMessage(), $e->getMessage(),
$e->getCode(), $e->getCode(),
(method_exists($e, 'getReportable') === true ? $e->getReportable() : true) (method_exists($e, 'getReportable') === true ? $e->getReportable() : true)
); );
$this->error_detail['file'] = $e->getFile();
$this->error_detail['line'] = $e->getLine();
$this->error_detail['trace'] = $e->getTrace();
$this->error_detail['extra'] = (method_exists($e, 'getExtraInfo') === true ? $e->getExtraInfo() : null);
try { try {
$database = database::get_instance(); $database = database::get_instance();
$this->error_detail['queries'] = $database->get_queries(); $this->error_detail['queries'] = $database->get_queries();