Title: Getting wp_error breaks
Last modified: December 10, 2016

---

# Getting wp_error breaks

 *  [Imagin](https://wordpress.org/support/users/imaginltd/)
 * (@imaginltd)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/getting-wp_error-breaks/)
 * _[ Moderator note: [moved to How-to and Troubleshooting](https://wordpress.org/support/topic/wheres-my-topic-gone?replies=1&view=all).]_
 * I have been using the following code to access WordPress errors; however, recently,
   this stopped working. It breaks any code following it and if submitting a form,
   leads to 500 page error. I have tried putting it in a try/catch, but the code
   somehow still breaks.
 * I use this to get the errors, which appears to work fine.
 *     ```
       public static function GetErrors()
       {
           static $wp_error;
           return isset($wp_error) ? $wp_error : ($wp_error = new WP_Error(null, null, null));
       }
       ```
   
 * Then I use this to get the error codes, which is what breaks.
 *     ```
       \MyNamespace\MyStaticClass::GetErrors() -> get_error_codes()
       ```
   

The topic ‘Getting wp_error breaks’ is closed to new replies.

## Tags

 * [errors](https://wordpress.org/support/topic-tag/errors/)
 * [wp_error](https://wordpress.org/support/topic-tag/wp_error/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Imagin](https://wordpress.org/support/users/imaginltd/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/getting-wp_error-breaks/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
