-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathray-debug.sublime-snippet
executable file
·92 lines (71 loc) · 2.29 KB
/
ray-debug.sublime-snippet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<snippet>
<content><![CDATA[
// Load Spatie Ray
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
// We have to load autoload.php.
require_once __DIR__ . '/vendor/autoload.php';
// You have to install it.
if ( file_exists( __DIR__ . '/vendor/spatie' ) ) {
/**
* Report errors to Spatie Ray.
*
* Add to your `wp-config.php` in WordPress.
* Make sure you `composer require spatie/ray`
* Make sure you ran `composer install`
*
* @author Aubrey Portwood <aubrey@webdevstudios.com>
* @since Monday, December 27, 2021
* @return void
*/
function ____error_to_spatie_ray() {
\$error = error_get_last();
if ( \$error === NULL ) {
return;
}
// Comment these out to ignore errors.
if ( in_array( true, [
/* Ignore Notices, Warnings, and Deprecations */
\$error['type'] === E_WARNING,
\$error['type'] === E_NOTICE,
// \$error['type'] === E_CORE_WARNING,
// \$error['type'] === E_COMPILE_WARNING,
// \$error['type'] === E_USER_WARNING,
// \$error['type'] === E_USER_NOTICE,
// \$error['type'] === E_STRICT,
// \$error['type'] === E_RECOVERABLE_ERROR,
// \$error['type'] === E_DEPRECATED,
// \$error['type'] === E_USER_DEPRECATED,
/* Ignore Errors */
// \$error['type'] === E_ERROR,
// \$error['type'] === E_PARSE,
// \$error['type'] === E_CORE_ERROR,
// \$error['type'] === E_COMPILE_ERROR,
// \$error['type'] === E_USER_ERROR,
], true ) ) {
// Don't show anything in Ray about these.
return;
}
// If we hit any of theses ERROR's, we'll show the app so you know.
if ( in_array( true, [
/* Errors */
// \$error['type'] === E_ERROR,
// \$error['type'] === E_PARSE,
// \$error['type'] === E_CORE_ERROR,
// \$error['type'] === E_COMPILE_ERROR,
// \$error['type'] === E_USER_ERROR,
], true ) ) {
// Log the error (in red) and show Ray.
\ray( \$error )->red();
return;
}
\ray( \$error ); // Just log the error to Ray (in red).
}
register_shutdown_function( '____error_to_spatie_ray' );
}
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>rrdebug</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.php</scope>
</snippet>