stackTrace($stackLength) ); } // Set the message $message = __($message, $variables); // Pass the message to the parent parent::__construct($message, $code); } /** * Big thank you to jhurliman and jambroseclarke on Stack Overflow for this backtrace formatter. * We have slightly modified it for our purposes * https://stackoverflow.com/a/32365961 */ private function stackTrace($Length = 25) { $stack = debug_backtrace($Length); $output = ''; $stackLen = count($stack); for ($i = 1; $i < $stackLen; $i++) { $entry = $stack[$i]; $func = $entry['function'] . '('; if(isset($entry['args'])){ $argsLen = count($entry['args']); for ($j = 0; $j < $argsLen; $j++) { $my_entry = $entry['args'][$j]; if (is_string($my_entry)) { $func .= $my_entry; } if ($j < $argsLen - 1) $func .= ', '; } } $func .= ')'; $entry_file = 'NO_FILE'; if (array_key_exists('file', $entry)) { $entry_file = str_replace(PATH_ROOT, '' , $entry['file']); } $entry_line = 'NO_LINE'; if (array_key_exists('line', $entry)) { $entry_line = $entry['line']; } $output .= $entry_file . ':' . $entry_line . ' - ' . $func . PHP_EOL; } return $output; } }