added status code check which throws exception