Improve error message for invalid URLs