Automattic\WooCommerce\Api\Infrastructure
GraphQLControllerBase::build_resolver_failure_response
Build the canonical 500 response used when the HTTP status resolver throws or returns an out-of-range value. Body shape matches an unhandled internal error so callers don't need a separate path for "resolver blew up".
In debug mode, attaches extensions.debug (message, file, line, trace) for the wrapper exception, plus an extensions.previous chain when the resolver itself threw — mirroring the shape that {@see self::format_exception()} produces for the generic-Throwable path. Outside debug mode the body stays purely generic so resolver internals never leak to anonymous callers.
Method of the class: GraphQLControllerBase{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->build_resolver_failure_response( $e, $request, ?object $principal ): \WP_REST_Response;
- $e(StatusResolverFailedException) (required)
- The wrapper exception thrown by {@see self::pick_status()}.
- $request(WP_REST_Request) (required)
- The originating REST request.
- ?object $principal(required)
- .
GraphQLControllerBase::build_resolver_failure_response() GraphQLControllerBase::build resolver failure response code WC 10.9.1
private function build_resolver_failure_response(
StatusResolverFailedException $e,
\WP_REST_Request $request,
?object $principal
): \WP_REST_Response {
$error = array(
'message' => 'An unexpected error occurred.',
'extensions' => array( 'code' => 'INTERNAL_ERROR' ),
);
if ( $this->is_debug_mode( $principal, $request ) ) {
$error['extensions']['debug'] = array(
'message' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTraceAsString(),
);
$chain = $this->extract_previous_chain( $e );
if ( ! empty( $chain ) ) {
$error['extensions']['previous'] = $chain;
}
}
return new \WP_REST_Response( array( 'errors' => array( $error ) ), 500 );
}