handling http status codes and throwing exception when not 200 (OK)