Add API request error handling. Relates to #15