mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
Merge branch 'MDL-76649' of https://github.com/timhunt/moodle
This commit is contained in:
commit
e0d857f39f
4 changed files with 73 additions and 20 deletions
|
@ -9307,6 +9307,25 @@ function mtrace($string, $eol="\n", $sleep=0) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to {@see mtrace()} an exception or throwable, including all relevant information.
|
||||
*
|
||||
* @param Throwable $e the error to ouptput.
|
||||
*/
|
||||
function mtrace_exception(Throwable $e): void {
|
||||
$info = get_exception_info($e);
|
||||
|
||||
$message = $info->message;
|
||||
if ($info->debuginfo) {
|
||||
$message .= "\n\n" . $info->debuginfo;
|
||||
}
|
||||
if ($info->backtrace) {
|
||||
$message .= "\n\n" . format_backtrace($info->backtrace, true);
|
||||
}
|
||||
|
||||
mtrace($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace 1 or more slashes or backslashes to 1 slash
|
||||
*
|
||||
|
|
|
@ -482,11 +482,12 @@ function is_early_init($backtrace) {
|
|||
|
||||
/**
|
||||
* Returns detailed information about specified exception.
|
||||
* @param exception $ex
|
||||
* @return object
|
||||
*
|
||||
* @param Throwable $ex any sort of exception or throwable.
|
||||
* @return stdClass standardised info to display. Fields are clear if you look at the end of this function.
|
||||
*/
|
||||
function get_exception_info($ex) {
|
||||
global $CFG, $DB, $SESSION;
|
||||
function get_exception_info($ex): stdClass {
|
||||
global $CFG;
|
||||
|
||||
if ($ex instanceof moodle_exception) {
|
||||
$errorcode = $ex->errorcode;
|
||||
|
|
|
@ -24,6 +24,7 @@ information provided here is intended especially for developers.
|
|||
* In outputcomponents.php, initials_bar() can now be rendered in a smaller (mini) way. This provides purely the
|
||||
initials bar without the bootstrapping and form handling on each initials bar. If you use this mini render,
|
||||
you'll need to implement your own form handling. Example usage can be found within the grader report.
|
||||
* There is a new helper function mtrace_exception to help with reporting exceptions you have caught in scheduled tasks.
|
||||
|
||||
=== 4.1 ===
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue