handling API failure