Adding some basic error-handling for API requests