Catching Salesforce Exceptions
Pretty simple, but for those new to PHP or to exception handling:
// instantiate a SOAP connection to Salesforce
// catch Salesforce exception if there is one
try {
$crmHandle->createConnection(SALESFORCE_WSDL);
} catch (Exception $e) {
// handle exception - did you set the WSDL path above?
// print out the exception string
echo $e->getMessage();
}
If an exception occurs, and it’s not caught, it behaves more or less like a fatal error. PHP’s set_exception_handler() function provides a nice fallback, allowing you to avoid try/catching every method call. That’s pretty much all there is to it.
