Skip to content
Snippets Groups Projects
Commit 1dd989ee authored by Lucas García's avatar Lucas García
Browse files

feat: submission error handling

parent 97fa2a06
No related branches found
No related tags found
1 merge request!3Git submodules
......@@ -52,7 +52,7 @@ abstract class Integration extends Singleton
$response = Wpct_Http_Client::post_multipart($url, $data, $uploads);
}
$success = $success && (bool) $response;
$success = $success && !is_wp_error($response);
}
}
......@@ -65,8 +65,9 @@ abstract class Integration extends Singleton
$to = $email;
$subject = 'Wpct ERP Forms Error';
$body = "Form ID: {$form_data['id']}\n";
$body .= "Form title: {$form_data['title']}";
$body .= 'Submission: ' . print_r($payload, true);
$body .= "Form title: {$form_data['title']}\n";
$body .= 'Submission: ' . print_r($payload, true) . "\n";
$body .= 'Error: ' . print_r($response->get_error_data(), true) . "\n";
$success = wp_mail($to, $subject, $body);
if (!$success) {
throw new Exception('Error while submitting form ' . $form_data['id']);
......@@ -203,7 +204,7 @@ abstract class Integration extends Singleton
]);
$res = Wpct_Http_Client::post($url, $payload);
if (!$res) {
if (is_wp_error($res)) {
throw new Exception('Error while establish RPC session');
}
......
Subproject commit 98b6d9e3729ef61c1c7fafd73e23f793633d2062
Subproject commit a94c92d29df6045583191097ba3fd5191636cac2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment