Throw exception when creating resource fails.