PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / boot / error_handler.php

error_handler.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at boot/error_handler.php

58 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2 <?php
3
4 //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler
5 set_error_handler(function($errno, $msg, $fn, $ln) use ($file) {
6
7 //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure_error_reporting
8 if (!(error_reporting() & $errno)) {
9 return false;
10 }
11
12 $levels = [
13 E_ALL => "E_ALL",
14 E_ERROR => "E_ERROR",
15 E_WARNING => "E_WARNING",
16 E_PARSE => "E_PARSE",
17 E_NOTICE => "E_NOTICE",
18 E_CORE_ERROR => "E_CORE_ERROR",
19 E_CORE_WARNING => "E_CORE_WARNING",
20 E_COMPILE_ERROR => "E_COMPILE_ERROR",
21 E_COMPILE_WARNING => "E_COMPILE_WARNING",
22 E_USER_ERROR => "E_USER_ERROR",
23 E_USER_WARNING => "E_USER_WARNING",
24 E_USER_NOTICE => "E_USER_NOTICE",
25 E_STRICT => "E_STRICT",
26 E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR",
27 E_DEPRECATED => "E_DEPRECATED",
28 E_USER_DEPRECATED => "E_USER_DEPRECATED"
29 ];
30
31 $levelName = $levels[$errno] ?? "UNKNOWN ERROR LEVEL";
32
33 // Improved debugging information
34 if (strpos($fn, dirname($file) . '/') !== false) {
35 $debugInfo = [
36 'Error Level' => $levelName,
37 'Message' => $msg,
38 'File' => $fn,
39 'Line' => $ln,
40 //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
41 'Backtrace' => debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)
42 ];
43
44 throw new ErrorException(sprintf(
45 /* translators: %1$s is the error level, %2$s is the error message, %3$s is the file name, %4$s is the line number, %5$s is the debug info */
46 '%s - %s in %s at line %s. Debug Info: %s',
47 esc_html($levelName),
48 esc_html($msg),
49 esc_html($fn),
50 absint($ln),
51 //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
52 esc_html(print_r($debugInfo, true))
53 ), 500);
54 }
55
56 return false;
57 });
58