diff --git a/changelog/add-add-wc-return-previous-exceptions-filter b/changelog/add-add-wc-return-previous-exceptions-filter new file mode 100644 index 00000000000..2ed58d22fff --- /dev/null +++ b/changelog/add-add-wc-return-previous-exceptions-filter @@ -0,0 +1,4 @@ +Significance: patch +Type: add + +Add woocommerce-return-previous-exceptions filter diff --git a/includes/class-wc-payment-gateway-wcpay.php b/includes/class-wc-payment-gateway-wcpay.php index d6fe41edb75..57988038e88 100644 --- a/includes/class-wc-payment-gateway-wcpay.php +++ b/includes/class-wc-payment-gateway-wcpay.php @@ -1289,6 +1289,8 @@ public function process_payment( $order_id ) { $order->add_order_note( $note ); } + // This allows WC to check if WP_DEBUG mode is enabled before returning previous Exception and expose Exception class name to frontend. + add_filter( 'woocommerce_return_previous_exceptions', '__return_true' ); // Re-throw the exception after setting everything up. // This makes the error notice show up both in the regular and block checkout. throw new Exception( WC_Payments_Utils::get_filtered_error_message( $e, $blocked_by_fraud_rules ), 0, $e );