add api error logging