You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The method Client::checkResults checks the array of results returned by the Salesforce APIs and throws a SaveException when at least one of the results is not a Success. However in a catch block one can only retrieve from the exception the results that were indeed a failure but there is no way to handle those that weren't. Wouldn't it better if the SaveException had a way to get all the results of a call?
I'm not sure what's the best way here, I can only think of adding all the results in the exception no matter what (the error message of the exception is still only bound to those results that has an error).
The text was updated successfully, but these errors were encountered:
We are unfortunately using this (apparently dead) library. To fix this we are commenting out the block that throws the exceptions. We will as you expect, iterate the results and deal with success/failure from there. Throwing an exception here seems silly.
I'd do a pull request for this but there are three open PR's going back as far as 2013...
Hopefully this helps someone else out in the future!
`protected function checkResult(array $results, array $params)
{
$exceptions = new Exception\SaveException();
for ($i = 0; $i < count($results); $i++) {
// If the param was an (s)object, set it’s Id field
if (is_object($params[$i])
&& (!isset($params[$i]->Id) || null === $params[$i]->Id)
&& $results[$i] instanceof Result\SaveResult) {
$params[$i]->Id = $results[$i]->getId();
}
if (!$results[$i]->isSuccess()) {
$results[$i]->setParam($params[$i]);
$exceptions->add($results[$i]);
}
}
//if ($exceptions->count() > 0) {
// throw $exceptions;
//}
return $results;
}`
The method Client::checkResults checks the array of results returned by the Salesforce APIs and throws a SaveException when at least one of the results is not a Success. However in a catch block one can only retrieve from the exception the results that were indeed a failure but there is no way to handle those that weren't. Wouldn't it better if the SaveException had a way to get all the results of a call?
I'm not sure what's the best way here, I can only think of adding all the results in the exception no matter what (the error message of the exception is still only bound to those results that has an error).
The text was updated successfully, but these errors were encountered: