It would be nice if the upsert() function would return a upsertResult object when called. Right now it's very hard to find out what went wrong when upsert isn't working.
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_upsert_upsertresult.htm