[wp-trac] [WordPress Trac] #60014: REST endpoint: Output "server errors" if WP_DEBUG = true (register_rest_route)

WordPress Trac noreply at wordpress.org
Wed Dec 6 17:29:51 UTC 2023


#60014: REST endpoint: Output "server errors" if WP_DEBUG = true
(register_rest_route)
-------------------------+------------------------------
 Reporter:  ecc          |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  REST API     |     Version:  6.4
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:  rest-api
-------------------------+------------------------------

Comment (by ecc):

 @spacedmonkey I looked at the new 6.3 developer mode. Looks very
 interesting.

 But i think, for the "server errors" output feature, checking WP_DEBUG and
 WP_DEBUG_DISPLAY maybe enough already.

 {{{#!php
 <?php
 if(
   defined('WP_DEBUG') && WP_DEBUG === true &&
   defined('WP_DEBUG_DISPLAY') && WP_DEBUG_DISPLAY === true
 ) {
   // Add current error / exception message to the JSON response.
 }
 }}}

 output:


 {{{
 {
     "code": "internal_server_error",
     "message": "<p>There has been a critical error on this website.<\/p>",
     "data": {
         "status": 500,
         "error": "Uncaught TypeError:
 PluginConfig::getWpOptionStorageName(): Return value must be of type
 array, string returned in ..."
     },
     "additional_errors": []
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60014#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list