I’m parsing the URL in Rails controller using URI.parse, i.e.
URI.parse(user_URL)
When the user inputs something such as %, the webpage raises the error
bad URI(is not URI?): %
and shows error page.
Rather, I’d like it to go to my page which says “Your URL % is not valid”. Is it possible?
Just wrap the
parsecall in abegin/endblock with arescuefor the case where the URL is invalid:Then in your
invalid_url_pagecontroller action (or whatever you call that action), you can access the invalid url withparams[:url]. In the view associated with that action, you can display the message “Your URL % is not valid” with: