WP_REST_Response vs WP_Error WP_REST_Response vs WP_Error wordpress wordpress

WP_REST_Response vs WP_Error


I do as follows:

WP_REST_Response // Used when endpoint code runs just fine but needs to                  // tell the client about some other downstream error (e.g. 4xx)
WP_Error // Used when endpoint code has an issue and needs to tell you         // it didn't compute or couldn't find resources etc (e.g. 5xx)