Throwing exception when a URL cannot be created