NetworkException constructor

NetworkException(
  1. String message, {
  2. Object? cause,
})

Thrown to indicate an I/O error during network operations.

This general-purpose exception wraps lower-level errors such as SocketException, HttpException, or HandshakeException to provide a consistent error type for networking failures.

Example:

try {
  final connection = HttpUrlConnection(Url.parse('https://example.com'));
  await connection.connect();
} on NetworkException catch (e) {
  print(e); // NetworkException: Failed to connect...
}

message should describe the problem clearly, and cause may contain a wrapped exception (e.g. SocketException, HttpException).

Implementation

NetworkException(super.message, {super.cause});