Handle errors, and log them, for most of the REST API calls