function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
venkatesh_d041.3888386112928691E12venkatesh_d041.3888386112928691E12 

Accessing the entire fault response from a CalloutException

This is an older problem  but got no further than promoting the Salesforce Idea: SOAPFault Information for Apex. It came up again today with users of a managed package wanting better error messages when a web service callout fails.

When this gets handled by Apex it gets turned into a CalloutException:

    System.CalloutException
    Cause: null
    Message: Web service callout failed: WebService returned a SOAP Fault: The creator of this fault did not specify a Reason. faultcode=s:Client faultactor=

The issue I have is that the getMessage() method doesn't return the entire SOAP reponse. It has been truncated before the useful information appears.

Is there some way to recover the entire response from the CalloutException in code so I can give a meaning error back to the user?


Thanks,
Venkat.
Vinita_SFDCVinita_SFDC
Hi Venkat,

Soap fault from salesforce always contains the stack trace with the error message as this  is the default behavior. There is no option to control it.
The only option is to build a wrapper on client side which can catch it and truncate the message.

Refer: http://salesforce.stackexchange.com/questions/29384/accessing-the-entire-fault-response-from-a-calloutexception