Changed logic to be able to override status code when throwing exception.