MalformedUrlException constructor

MalformedUrlException(
  1. String message, {
  2. Uri? uri,
})

Thrown to indicate that a malformed URL has occurred.

This exception is used when a Url or Uri string does not conform to expected format or cannot be parsed properly.

Example:

try {
  final url = Url.parse('ht!tp://::invalid-url');
} on MalformedUrlException catch (e) {
  print(e); // MalformedUrlException: Invalid scheme (URL: ht!tp://::invalid-url)
}

message describes the specific error, and uri is the invalid URI.

Implementation

MalformedUrlException(super.message, {this.uri});