mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Use AssertionError rather than Exceptions for unexpected behaviour in io.
Follow up to https://dart-review.googlesource.com/c/sdk/+/257140/comments/38b33a34_5c1914ff. Unreachable code in error handling. Change-Id: I9e8a5b19372d63a604efcdf9856a618e5f7b520f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258513 Commit-Queue: Kallen Tu <kallentu@google.com> Reviewed-by: Lasse Nielsen <lrn@google.com>
This commit is contained in:
parent
c76c37c254
commit
a3764263d8
|
@ -1549,23 +1549,23 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
|
|||
static createError(error, String message,
|
||||
[InternetAddress? address, int? port]) {
|
||||
if (error is OSError) {
|
||||
return new SocketException(message,
|
||||
return SocketException(message,
|
||||
osError: error, address: address, port: port);
|
||||
} else if (error is List) {
|
||||
assert(isErrorResponse(error));
|
||||
switch (error[0]) {
|
||||
case _illegalArgumentResponse:
|
||||
return new ArgumentError();
|
||||
return ArgumentError();
|
||||
case _osErrorResponse:
|
||||
return new SocketException(message,
|
||||
osError: new OSError(error[2], error[1]),
|
||||
return SocketException(message,
|
||||
osError: OSError(error[2], error[1]),
|
||||
address: address,
|
||||
port: port);
|
||||
default:
|
||||
return new Exception("Unknown error");
|
||||
return AssertionError("Unknown error");
|
||||
}
|
||||
} else {
|
||||
return new SocketException(message, address: address, port: port);
|
||||
return SocketException(message, address: address, port: port);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ void _checkForErrorResponse(Object? response, String message, String path) {
|
|||
case _fileClosedResponse:
|
||||
throw FileSystemException("File closed", path);
|
||||
default:
|
||||
throw Exception("Unknown error");
|
||||
throw AssertionError("Unknown error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@ class _Directory extends FileSystemEntity implements Directory {
|
|||
response[_osErrorResponseErrorCode] as int);
|
||||
throw FileSystemException(message, path, err);
|
||||
default:
|
||||
throw Exception("Unknown error");
|
||||
throw AssertionError("Unknown error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ class _Link extends FileSystemEntity implements Link {
|
|||
response[_osErrorResponseErrorCode] as int);
|
||||
throw FileSystemException(message, path, err);
|
||||
default:
|
||||
throw Exception("Unknown error");
|
||||
throw AssertionError("Unknown error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue