From 15e9f2138f83a2eeca2c92b8cf741bbf66938f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 13 Sep 2016 14:23:21 +0200 Subject: [PATCH] MDL-55951 output: Add errorcode to fatal_error when available --- lib/outputrenderers.php | 7 ++++--- lib/setuplib.php | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index d0d5b2327db..0dabdb58626 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -2766,7 +2766,7 @@ EOD; * @param string $debuginfo Debugging information * @return string the HTML to output. */ - public function fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null) { + public function fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null, $errorcode = "") { global $CFG; $output = ''; @@ -4335,7 +4335,7 @@ class core_renderer_cli extends core_renderer { * @param string $debuginfo Debugging information * @return string A template fragment for a fatal error */ - public function fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null) { + public function fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null, $errorcode = "") { global $CFG; $output = "!!! $message !!!\n"; @@ -4410,13 +4410,14 @@ class core_renderer_ajax extends core_renderer { * @param string $debuginfo Debugging information * @return string A template fragment for a fatal error */ - public function fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null) { + public function fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null, $errorcode = "") { global $CFG; $this->page->set_context(null); // ugly hack - make sure page context is set to something, we do not want bogus warnings here $e = new stdClass(); $e->error = $message; + $e->errorcode = $errorcode; $e->stacktrace = NULL; $e->debuginfo = NULL; $e->reproductionlink = NULL; diff --git a/lib/setuplib.php b/lib/setuplib.php index fbaf5884e02..ee66310219f 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -384,7 +384,8 @@ function default_exception_handler($ex) { // If you enable db debugging and exception is thrown, the print footer prints a lot of rubbish $DB->set_debug(0); } - echo $OUTPUT->fatal_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo); + echo $OUTPUT->fatal_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo, + $info->errorcode); } catch (Exception $e) { $out_ex = $e; } catch (Throwable $e) {