diff --git a/modules/salesforce_mapping/src/Entity/MappedObject.php b/modules/salesforce_mapping/src/Entity/MappedObject.php index ad73d3d63881fa571ee08d8f2e23f0d8909565fd..5c5902d213751c57f1f48ac8f0848d4519bb7305 100644 --- a/modules/salesforce_mapping/src/Entity/MappedObject.php +++ b/modules/salesforce_mapping/src/Entity/MappedObject.php @@ -393,6 +393,7 @@ class MappedObject extends RevisionableContentEntityBase implements MappedObject $value = $this->sf_object->field($field->get('salesforce_field')); } catch (Exception $e) { + // Field missing from SObject? Skip it. continue; } @@ -402,7 +403,6 @@ class MappedObject extends RevisionableContentEntityBase implements MappedObject } catch (\Exception $e) { $message = t(); - // throw new \Exception($message, $e->getCode(), $e); \Drupal::logger('Salesforce Pull')->notice('Exception during pull for @sfobj.@sffield @sfid to @dobj.@dprop @did with value @v: @e', [ '@sfobj' => $mapping->getSalesforceObjectType(), '@sffield' => $sf_field, @@ -413,6 +413,7 @@ class MappedObject extends RevisionableContentEntityBase implements MappedObject '@v' => $value, '@e' => $e->getMessage(), ]); + watchdog_exception(__CLASS__, $e); continue; } } diff --git a/modules/salesforce_mapping/src/Form/MappedObjectForm.php b/modules/salesforce_mapping/src/Form/MappedObjectForm.php index 44637fe3328f79db8a3a110f90325a8f12faf04f..a1062be63c76d447383ea0b32bd2c5656cdee32d 100644 --- a/modules/salesforce_mapping/src/Form/MappedObjectForm.php +++ b/modules/salesforce_mapping/src/Form/MappedObjectForm.php @@ -106,6 +106,7 @@ class MappedObjectForm extends ContentEntityForm { $mapped_object->push(); } catch (Exception $e) { + watchdog_exception(__CLASS__, $e); drupal_set_message(t('Push failed with an exception: %exception', array('%exception' => $e->getMessage())), 'error'); return; } diff --git a/modules/salesforce_mapping/src/Form/SalesforceMappingFormCrudBase.php b/modules/salesforce_mapping/src/Form/SalesforceMappingFormCrudBase.php index b7cdc97102e08b086ef7f02f74e33a31819ac643..07fc8429ea18167a3fb654acf2b68103fa11bb9a 100644 --- a/modules/salesforce_mapping/src/Form/SalesforceMappingFormCrudBase.php +++ b/modules/salesforce_mapping/src/Form/SalesforceMappingFormCrudBase.php @@ -397,7 +397,7 @@ abstract class SalesforceMappingFormCrudBase extends SalesforceMappingFormBase { } } catch (\Exception $e) { - // noop + // No record type info means nothing for us to do. } return $sf_types; } @@ -434,6 +434,7 @@ abstract class SalesforceMappingFormCrudBase extends SalesforceMappingFormBase { $describe = $this->get_salesforce_object(); } catch (Exception $e) { + // No describe results means no datetime fields. We're done. return []; } diff --git a/modules/salesforce_mapping/src/Plugin/SalesforceMappingField/RelatedProperties.php b/modules/salesforce_mapping/src/Plugin/SalesforceMappingField/RelatedProperties.php index 4d568ddaf9b127a058beab3bc1f40da4a5a6ca27..09af4780636f2c2e8b610d0add547a198b4d5730 100644 --- a/modules/salesforce_mapping/src/Plugin/SalesforceMappingField/RelatedProperties.php +++ b/modules/salesforce_mapping/src/Plugin/SalesforceMappingField/RelatedProperties.php @@ -79,6 +79,7 @@ class RelatedProperties extends SalesforceMappingFieldPluginBase { } catch (Exception $e) { // @TODO something about this exception + watchdog_exception(__CLASS__, $e); return; } diff --git a/modules/salesforce_pull/src/DeleteHandler.php b/modules/salesforce_pull/src/DeleteHandler.php index 8a2b735b8cfb71588bea68b8c1873e14e1eb1001..17a72e23ad6e53dd4efd246827d259eb61bb148b 100644 --- a/modules/salesforce_pull/src/DeleteHandler.php +++ b/modules/salesforce_pull/src/DeleteHandler.php @@ -73,13 +73,8 @@ class DeleteHandler { $mapped_objects = salesforce_mapped_object_load_by_sfid($record['id']); } catch (Exception $e) { - // @TODO do we need a log entry for every object which gets deleted and isn't mapped to Drupal? - \Drupal::logger('Salesforce Pull')->notice( - 'No mapped object exists for Salesforce Object ID: %sfid', - [ - '%sfid' => $record['id'], - ] - ); + // We do not need to know about every object which gets deleted in SF and + // isn't mapped to Drupal. return; } @@ -138,7 +133,7 @@ class DeleteHandler { ); } catch (Exception $e) { - \Drupal::logger('Salesforce Pull')->error($e); + watchdog_exception(__CLASS__, $e); // If mapped entity couldn't be deleted, do not delete the mapped object either. continue; } diff --git a/modules/salesforce_pull/src/Plugin/QueueWorker/PullBase.php b/modules/salesforce_pull/src/Plugin/QueueWorker/PullBase.php index df59402da54a62c23891dcdc0328156376f0e64b..20ab881d2ffe149fdc78a9f554fbe20a575f6542 100644 --- a/modules/salesforce_pull/src/Plugin/QueueWorker/PullBase.php +++ b/modules/salesforce_pull/src/Plugin/QueueWorker/PullBase.php @@ -123,6 +123,7 @@ abstract class PullBase extends QueueWorkerBase { ] ); \Drupal::logger('Salesforce Pull')->error($message); + watchdog_exception(__CLASS__, $e); } } @@ -205,6 +206,7 @@ abstract class PullBase extends QueueWorkerBase { ] ); \Drupal::logger('Salesforce Pull')->error($message); + watchdog_exception(__CLASS__, $e); } } diff --git a/modules/salesforce_pull/src/QueueHandler.php b/modules/salesforce_pull/src/QueueHandler.php index c188165dd6f7c009c48520c83b1c620250a24001..ac44b16083daa5a28ec51bae8d1f7f20d1317378 100644 --- a/modules/salesforce_pull/src/QueueHandler.php +++ b/modules/salesforce_pull/src/QueueHandler.php @@ -114,7 +114,7 @@ class QueueHandler { return $this->sfapi->query($soql); } catch (Exception $e) { - \Drupal::logger('Salesforce Pull')->error($e->getMessage()); + watchdog_exception(__CLASS__, $e); } } @@ -134,7 +134,7 @@ class QueueHandler { $this->handleLargeRequests($mapping, $new_result); } catch (Exception $e) { - \Drupal::logger('Salesforce Pull')->error($e->getMessage()); + watchdog_exception(__CLASS__, $e); } } } @@ -152,7 +152,7 @@ class QueueHandler { } } catch (Exception $e) { - \Drupal::logger('Salesforce Pull')->error($e->getMessage()); + watchdog_exception(__CLASS__, $e); } } } diff --git a/src/Form/AuthorizeForm.php b/src/Form/AuthorizeForm.php index 750c9872c2e24cab36a5da5b51a4b6dc4afb6a34..ec996899ce9178b72ef20f6f1cf7de9e75adc654 100644 --- a/src/Form/AuthorizeForm.php +++ b/src/Form/AuthorizeForm.php @@ -2,7 +2,7 @@ namespace Drupal\salesforce\Form; -use GuzzleHttp\Exception\ClientException; +use GuzzleHttp\Exception\RequestException; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; @@ -119,7 +119,8 @@ class AuthorizeForm extends ConfigFormBase { '#theme' => 'item_list', ]; } - catch (ClientException $e) { + catch (RequestException $e) { + watchdog_exception(__CLASS__, $e); salesforce_set_message($e->getMessage(), 'warning'); } } @@ -153,8 +154,9 @@ class AuthorizeForm extends ConfigFormBase { ); $response->send(); } - catch (ClientException $e) { - // Set form error. + catch (RequestException $e) { + drupal_set_message(t("Error during authorization: %message", $e->getMessage()), 'error'); + watchdog_exception(__CLASS__, $e); } parent::submitForm($form, $form_state); diff --git a/src/Rest/RestClient.php b/src/Rest/RestClient.php index 1ed448658bd52e1127f6d1ccfedc0e2334fef5c6..b3638f28a91f90971758f4f7b941c78f827b6ff9 100644 --- a/src/Rest/RestClient.php +++ b/src/Rest/RestClient.php @@ -90,7 +90,6 @@ class RestClient { catch (RequestException $e) { // RequestException gets thrown for any response status but 2XX. $this->response = $e->getResponse(); - switch ($this->response->getStatusCode()) { case 401: // The session ID or OAuth token used has expired or is invalid: refresh