Skip to content

Instantly share code, notes, and snippets.

@KevinBatdorf
Created March 24, 2021 01:59
Show Gist options
  • Save KevinBatdorf/dad7288386a3ab8656b123170625b50b to your computer and use it in GitHub Desktop.
Save KevinBatdorf/dad7288386a3ab8656b123170625b50b to your computer and use it in GitHub Desktop.
Add a Ray by Spatie helper to catch WP Errors
<?php
/*
* Create a file at wp-content/mu-plugins/ray-wp-error-helper.php and add this entire gist
* https://myray.app/
*/
add_action('wp_error_added', function ($code, $message, $data, $wp_error) {
ray($wp_error);
ray()->trace();
}, 10, 4);
@KevinBatdorf
Copy link
Author

Should see something like this:
Screen Shot 2021-03-23 at 9 59 43 PM

@KevinBatdorf
Copy link
Author

To generate the above, I had this in my code, but that filter will pick up on all internal WP errors as well as any custom errors.

new \WP_Error('example_error', __('Something really bad is happening.'), ['user' => get_current_user()]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment