catch error when api is invalid