From f9c09e2f473e20efa0f22139d9fcacebe9bbad15 Mon Sep 17 00:00:00 2001 From: Andrei Mondoc <andreimondoc@gmail.com> Date: Tue, 4 Feb 2020 14:16:59 +0000 Subject: [PATCH] accept instance of WP_Error Signed-off-by: Kevin Cristiano <kcristiano@kcristiano.com> --- wp-rest/Controller/Base.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-rest/Controller/Base.php b/wp-rest/Controller/Base.php index 7546377e9e..61ab9b3c63 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 ); -- GitLab