handle api failure gracefully