Detecting if resource exists and throw if not