Skip to content

Commit

Permalink
fix: return error response on error
Browse files Browse the repository at this point in the history
  • Loading branch information
ravinderk committed Oct 16, 2023
1 parent 08e9028 commit 4a1148f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/e2e/test-plugins/woocommerce-utils/woocommerce-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
'methods' => 'DELETE',
'permission_callback' => '__return_true',
'callback' => function () {
WC_Log_Handler_File::delete_logs_before_timestamp( strtotime( '+2 day' ) );
try {
WC_Log_Handler_File::delete_logs_before_timestamp( strtotime( '+2 day' ) );
} catch ( Exception $e ) {
return new WP_REST_Response( false, 500 );
}

return new WP_REST_Response( true, 200 );
},
Expand All @@ -27,7 +31,12 @@
'methods' => 'DELETE',
'callback' => function () {
global $wpdb;
$wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}email_log" );

try {
$wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}email_log" );
} catch ( Exception $e ) {
return new WP_REST_Response( false, 500 );
}

return new WP_REST_Response( true, 200 );
},
Expand Down

0 comments on commit 4a1148f

Please sign in to comment.