check http return codes and throw exception in case of error