Re: [whatwg/url] Consider adding non-throwing URL.parse(input, base) (#372)

I read through the linked thread but don't see a convincing rationale.

> After all, often these strings come as user input, and so it's not "exceptional" for them to be unparseable.

I would say at the layer of the `URL` API they _are_ exceptional. If they are not exceptional in your application logic because they come from user input, you can catch the error, which makes it non-exceptional at the correct layer.

Even if the implementations don't do this at the moment, the benefit of an exception is that the error can include a nice error message explaining why the URL is invalid, e.g. "Character \u1234 is not allowed in URL" or "Port segment can only contain numbers, found character 'a'". If the URL truly comes from user input, that is a nicer message to display to the user than "Invalid URL".

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/372#issuecomment-429630864

Received on Sunday, 14 October 2018 14:27:59 UTC