Skip to content

Commit

Permalink
Improve exception message with insert data.
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed May 3, 2024
1 parent fab69e2 commit aa1006a
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/CustomerDataStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,28 @@ public function connect_mollie_customer_to_wp_user( $customer, \WP_User $user )
return;
}

$data = [
'customer_id' => $customer->get_id(),
'user_id' => $user->ID,
];

$format = [
'customer_id' => '%d',
'user_id' => '%d',
];

$result = $wpdb->insert(
$wpdb->pronamic_pay_mollie_customer_users,
[
'customer_id' => $customer->get_id(),
'user_id' => $user->ID,
],
[
'customer_id' => '%d',
'user_id' => '%d',
]
$data,
$format
);

if ( false === $result ) {
throw new \Exception(
\sprintf(
'Database error: %s.',
\esc_html( $wpdb->last_error )
'Database error: %s, Data: %s.',
\esc_html( $wpdb->last_error ),
\esc_html( \wp_json_encode( $data ) )
)
);
}
Expand Down

0 comments on commit aa1006a

Please sign in to comment.