Automattic\WooCommerce\Internal
RestApiControllerBase::internal_wp_error()
Return an WP_Error object for an internal server error, with exception information if the current user is an admin.
Method of the class: RestApiControllerBase{}
No Hooks.
Return
WP_Error
.
Usage
// protected - for code of main (parent) or child class $result = $this->internal_wp_error( $exception ): WP_Error;
- $exception(Exception) (required)
- The exception to maybe include information from.
RestApiControllerBase::internal_wp_error() RestApiControllerBase::internal wp error code WC 9.6.0
protected function internal_wp_error( Exception $exception ): WP_Error { $data = array( 'status' => 500 ); if ( current_user_can( 'manage_woocommerce' ) ) { $data['exception_class'] = get_class( $exception ); $data['exception_message'] = $exception->getMessage(); $data['exception_trace'] = (array) $exception->getTrace(); } $data['exception_message'] = $exception->getMessage(); return new WP_Error( 'woocommerce_rest_internal_error', __( 'Internal server error', 'woocommerce' ), $data ); }