In all of the "try" "catches" I've seen so far, we're logging the error which is very good.

I have a need to do more than log the message. In my case, I need to send an email when an exception occurs.

What about adding a hook in the "catch" for these rather critical errors? I'd be willing to write the code.

Comments

kostajh’s picture

I think this is fine. What do others think?

aaronbauman’s picture

this is a prime use case for hook_watchdog()

dpearcefl’s picture

Status: Active » Closed (won't fix)

Good idea. Closing the issue.

stella’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
Status: Closed (won't fix) » Needs review
StatusFileSize
new1.37 KB

Sorry to reopen this issue, but it is very similar to something I need to do. For me, hook_watchdog() isn't enough. For all failure to submit data to Salesforce, I not only need to send an email with the error, but also need to record the entity type, entity id, error message and mapping params so an administrator can access report later and see exactly which submissions failed and why, and hopefully be able to fix them or manually create the Leads in Salesforce.

The attached patch invokes a hook on all REST push events, which allows other modules to react to a push failure. I haven't implemented it for SOAP as I'm not set up to test with that yet and wanted to see what you think of this approach first anyway.

aaronbauman’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev
Component: Code » salesforce_push.module
aaronbauman’s picture

Issue summary: View changes
StatusFileSize
new5.4 KB

OK, stella, your concern makes sense.

However, this patch adds quite a bit of additional duplication.
I've refactored this to implement salesforce_push_salesforce_push_failure(), which I think consolidates some of this nicely.

Also added documentation for this hook

tauno’s picture

Title: Adding a hook for a "try" exception » Add push success/failure hooks for REST
Status: Needs review » Needs work

This duplicates (or almost duplicates) the hook_salesforce_push_fail hook you committed a little while back - except it's implemented for SOAP and not REST. Shouldn't be too hard make the two success/failure hooks work for REST requests as well as SOAP. Revised patch welcome!

kenorb’s picture

aaronbauman’s picture

Status: Needs work » Needs review
StatusFileSize
new6.61 KB

re-rolled @ dev per #7

  • mariacha1 committed 79053fc on 7.x-3.x authored by aaronbauman
    Issue #1118736 by aaronbauman, stella: Add push success/failure hooks...
mariacha1’s picture

Status: Needs review » Fixed
mariacha1’s picture

Version: 7.x-3.x-dev » 8.x-3.x-dev
Status: Fixed » Patch (to be ported)

Not !00% sure about porting this one.

aaronbauman’s picture

Status: Patch (to be ported) » Fixed

This is into 8.x
see SalesforceEvents

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.