Versions:

Exceptions

There are two Exceptions that can be thrown by the Url class:

  • InvalidUrlException when you try to create an instance from a string that isn't a valid Uri.
  • InvalidUrlComponentException when you try to set an invalid new value for a component (scheme, host,...).

When you're dealing with unpredictable input source, you should catch and handle them somehow.