diff --git a/wp-rest/Controller/Base.php b/wp-rest/Controller/Base.php index 7546377e9e0973103beeaf4fff5e9789df04070c..61ab9b3c63d6f239992cb464bdff3e1224b8d50a 100644 --- a/wp-rest/Controller/Base.php +++ b/wp-rest/Controller/Base.php @@ -88,7 +88,7 @@ abstract class Base extends \WP_REST_Controller implements Endpoint_Interface { * Wrapper for WP_Error. * * @since 0.1 - * @param string|\CiviCRM_API3_Exception $error + * @param string|\CiviCRM_API3_Exception|\WP_Error $error * @param mixed $data Error data * @return WP_Error $error */ @@ -98,6 +98,10 @@ abstract class Base extends \WP_REST_Controller implements Endpoint_Interface { return $error->getExtraParams(); + } elseif ( $error instanceof \WP_Error ) { + + return $error; + } return new \WP_Error( 'civicrm_rest_api_error', $error, empty( $data ) ? [ 'status' => $this->authorization_status_code() ] : $data );