Error handling for effective and efficient use of APIs