Refactor error handling when making SF REST API calls using the request module.

Sporadically, in my production code, I've seen cases where calls made with the request module return no `err` or `res` values in the callback (this happens when sockets get closed).  This pull request tightens up the error handling code to protect against these circumstances, as well as some refactoring to eliminate code duplication.