Verified Commit bc23b0ef authored by Andrei Mondoc's avatar Andrei Mondoc Committed by Kevin Cristiano

accept instance of WP_Error

Signed-off-by: Kevin Cristiano's avatarKevin Cristiano <kcristiano@kcristiano.com>
parent 338cfc1a
......@@ -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 );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment