aam_rest_get_error_response_filter
Purpose
Provide a REST error response for premium handlers. Premium.
Callback
- Type: Filter.
- Arguments:
$response,$exception. - Return: the filtered first argument.
Example
add_filter('aam_rest_get_error_response_filter', function ($response, $exception) {
if ($response === null && $exception instanceof InvalidArgumentException) {
return new WP_Error('myapp_bad_request', $exception->getMessage(), ['status' => 400]);
}
return $response;
}, 10, 2);
Converts one exception type to a REST error and preserves a response already supplied by another callback.
See the complete hook list.