Fix bug in error logging during persistence.

I noticed that when getting errors back from Salesforce, I always got this NameError about "error." After digging into the code and the revision history, it seems this method was pulled out during a refactoring and over time, it was broken.

I've reworked the method so that it doesn't error anymore and added a spec.