handle errors reported as JSON, `{"error":...`

At least on OS X, the current version of sc is reporting credentials
errors as:

`Response: {"error": "Not authorized"}.`

Break out error handling function and apply it to existing string as
well as the string `"{\"error\":"`.