Clean up dart:io exceptions.

- Introduce IOException.
- Remove HttpParserException.
- Merge RedirectLimitExceededException and RedirectLoopException into
RedirectException.
- Remove 'IO' from FileIOException, DirectoryIOException, LinkIOException
and SocketIOException.

BUG=https://code.google.com/p/dart/issues/detail?id=9955
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//16123036

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23848 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
ajohnsen@google.com 2013-06-11 13:15:46 +00:00
parent 09bb36b8db
commit 5ce3b9ddea
59 changed files with 300 additions and 303 deletions

View file

@ -57,7 +57,7 @@ void main() {
request.headers[HttpHeaders.CONTENT_TYPE] =
'application/json; charset=utf-8';
expect(client.send(request), throwsSocketIOException);
expect(client.send(request), throwsSocketException);
request.sink.add('{"hello": "world"}'.codeUnits);
request.sink.close();

View file

@ -50,9 +50,9 @@ class SafeHttpServer extends StreamView<HttpRequest> implements HttpServer {
// Ignore socket error 104, which is caused by a request being cancelled
// before it writes any headers. There's no reason to care about such
// requests.
if (error is SocketIOException && error.osError.errorCode == 104) return;
if (error is SocketException && error.osError.errorCode == 104) return;
// Ignore any parsing errors, which come from malformed requests.
if (error is HttpParserException) return;
if (error is HttpException) return;
// Manually handle cancelOnError so the above (ignored) errors don't
// cause unsubscription.
if (cancelOnError) subscription.cancel();

View file

@ -196,14 +196,14 @@ class _RedirectLimitExceededException extends TypeMatcher {
item is RedirectLimitExceededException;
}
/// A matcher for SocketIOExceptions.
const isSocketIOException = const _SocketIOException();
/// A matcher for SocketExceptions.
const isSocketException = const _SocketException();
/// A matcher for functions that throw SocketIOException.
const Matcher throwsSocketIOException =
const Throws(isSocketIOException);
/// A matcher for functions that throw SocketException.
const Matcher throwsSocketException =
const Throws(isSocketException);
class _SocketIOException extends TypeMatcher {
const _SocketIOException() : super("SocketIOException");
bool matches(item, MatchState matchState) => item is SocketIOException;
class _SocketException extends TypeMatcher {
const _SocketException() : super("SocketException");
bool matches(item, MatchState matchState) => item is SocketException;
}

View file

@ -50,9 +50,9 @@ class SafeHttpServer extends StreamView<HttpRequest> implements HttpServer {
// Ignore socket error 104, which is caused by a request being cancelled
// before it writes any headers. There's no reason to care about such
// requests.
if (error is SocketIOException && error.osError.errorCode == 104) return;
if (error is SocketException && error.osError.errorCode == 104) return;
// Ignore any parsing errors, which come from malformed requests.
if (error is HttpParserException) return;
if (error is HttpException) return;
// Manually handle cancelOnError so the above (ignored) errors don't
// cause unsubscription.
if (cancelOnError) subscription.cancel();

View file

@ -38,16 +38,16 @@ void main() {
test('test 2', () {
expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
// TODO(nweiz): There can be three errors due to issue 9151. The
// HttpParserException is reported without a stack trace, and so when it's
// HttpException is reported without a stack trace, and so when it's
// wrapped twice it registers as a different exception each time (because
// it's given an ad-hoc stack trace). Always expect two exceptions when
// issue 9151 is fixed.
expect(errors.length, inInclusiveRange(2, 3));
expect(errors[0].error, equals("'scheduled server 0' received GET /hello "
"when no more requests were expected."));
expect(errors[1].error, new isInstanceOf<HttpParserException>());
expect(errors[1].error, new isInstanceOf<HttpException>());
if (errors.length > 2) {
expect(errors[2].error, new isInstanceOf<HttpParserException>());
expect(errors[2].error, new isInstanceOf<HttpException>());
}
});
}, passing: ['test 2']);
@ -110,16 +110,16 @@ void main() {
test('test 2', () {
// TODO(nweiz): There can be three errors due to issue 9151. The
// HttpParserException is reported without a stack trace, and so when it's
// HttpException is reported without a stack trace, and so when it's
// wrapped twice it registers as a different exception each time (because
// it's given an ad-hoc stack trace). Always expect two exceptions when
// issue 9151 is fixed.
expect(errors.length, inInclusiveRange(2, 3));
expect(errors[0].error, equals("'scheduled server 0' received GET /hello "
"earlier than expected."));
expect(errors[1].error, new isInstanceOf<HttpParserException>());
expect(errors[1].error, new isInstanceOf<HttpException>());
if (errors.length > 2) {
expect(errors[2].error, new isInstanceOf<HttpParserException>());
expect(errors[2].error, new isInstanceOf<HttpException>());
}
expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
});
@ -166,16 +166,16 @@ void main() {
test('test 2', () {
// TODO(nweiz): There can be three errors due to issue 9151. The
// HttpParserException is reported without a stack trace, and so when it's
// HttpException is reported without a stack trace, and so when it's
// wrapped twice it registers as a different exception each time (because
// it's given an ad-hoc stack trace). Always expect two exceptions when
// issue 9151 is fixed.
expect(errors.length, inInclusiveRange(2, 3));
expect(errors[0].error, equals("'scheduled server 0' expected GET "
"/goodbye, but got GET /hello."));
expect(errors[1].error, new isInstanceOf<HttpParserException>());
expect(errors[1].error, new isInstanceOf<HttpException>());
if (errors.length > 2) {
expect(errors[2].error, new isInstanceOf<HttpParserException>());
expect(errors[2].error, new isInstanceOf<HttpException>());
}
});
}, passing: ['test 2']);
@ -199,16 +199,16 @@ void main() {
test('test 2', () {
// TODO(nweiz): There can be three errors due to issue 9151. The
// HttpParserException is reported without a stack trace, and so when it's
// HttpException is reported without a stack trace, and so when it's
// wrapped twice it registers as a different exception each time (because
// it's given an ad-hoc stack trace). Always expect two exceptions when
// issue 9151 is fixed.
expect(errors.length, inInclusiveRange(2, 3));
expect(errors[0].error, equals("'scheduled server 0' expected GET "
"/hello, but got HEAD /hello."));
expect(errors[1].error, new isInstanceOf<HttpParserException>());
expect(errors[1].error, new isInstanceOf<HttpException>());
if (errors.length > 2) {
expect(errors[2].error, new isInstanceOf<HttpParserException>());
expect(errors[2].error, new isInstanceOf<HttpException>());
}
});
}, passing: ['test 2']);
@ -304,16 +304,16 @@ void main() {
test('test 2', () {
// TODO(nweiz): There can be three errors due to issue 9151. The
// HttpParserException is reported without a stack trace, and so when it's
// HttpException is reported without a stack trace, and so when it's
// wrapped twice it registers as a different exception each time (because
// it's given an ad-hoc stack trace). Always expect two exceptions when
// issue 9151 is fixed.
expect(errors.length, inInclusiveRange(2, 3));
expect(errors[0].error, equals("'scheduled server 0' received GET "
"/hello/3 when no more requests were expected."));
expect(errors[1].error, new isInstanceOf<HttpParserException>());
expect(errors[1].error, new isInstanceOf<HttpException>());
if (errors.length > 2) {
expect(errors[2].error, new isInstanceOf<HttpParserException>());
expect(errors[2].error, new isInstanceOf<HttpException>());
}
});
}, passing: ['test 2']);
@ -336,15 +336,15 @@ void main() {
test('test 2', () {
// TODO(nweiz): There can be three errors due to issue 9151. The
// HttpParserException is reported without a stack trace, and so when it's
// HttpException is reported without a stack trace, and so when it's
// wrapped twice it registers as a different exception each time (because
// it's given an ad-hoc stack trace). Always expect two exceptions when
// issue 9151 is fixed.
expect(errors.length, inInclusiveRange(2, 3));
expect(errors[0].error, equals('oh no'));
expect(errors[1].error, new isInstanceOf<HttpParserException>());
expect(errors[1].error, new isInstanceOf<HttpException>());
if (errors.length > 2) {
expect(errors[2].error, new isInstanceOf<HttpParserException>());
expect(errors[2].error, new isInstanceOf<HttpException>());
}
});
}, passing: ['test 2']);

View file

@ -760,10 +760,10 @@ Dart_Handle DartUtils::NewDartOSError(OSError* os_error) {
}
Dart_Handle DartUtils::NewDartSocketIOException(const char* message,
Dart_Handle os_error) {
// Create a dart:io SocketIOException object.
Dart_Handle clazz = GetDartClass(kIOLibURL, "SocketIOException");
Dart_Handle DartUtils::NewDartSocketException(const char* message,
Dart_Handle os_error) {
// Create a dart:io SocketException object.
Dart_Handle clazz = GetDartClass(kIOLibURL, "SocketException");
Dart_Handle args[2];
args[0] = NewString(message);
args[1] = os_error;

View file

@ -140,8 +140,8 @@ class DartUtils {
static Dart_Handle NewDartOSError();
// Create a new Dart OSError object with the provided OS error.
static Dart_Handle NewDartOSError(OSError* os_error);
static Dart_Handle NewDartSocketIOException(const char* message,
Dart_Handle os_error);
static Dart_Handle NewDartSocketException(const char* message,
Dart_Handle os_error);
static Dart_Handle NewDartExceptionWithMessage(const char* library_url,
const char* exception_name,
const char* message);

View file

@ -394,7 +394,7 @@ bool SyncDirectoryListing::HandleError(const char* dir_name) {
args[1] = DartUtils::NewString(dir_name);
args[2] = dart_os_error;
Dart_ThrowException(Dart_New(
DartUtils::GetDartClass(DartUtils::kIOLibURL, "DirectoryIOException"),
DartUtils::GetDartClass(DartUtils::kIOLibURL, "DirectoryException"),
Dart_Null(),
3,
args));

View file

@ -26,9 +26,9 @@ namespace dart {
namespace bin {
static void ThrowException(const char* message) {
Dart_Handle socket_io_exception =
DartUtils::NewDartSocketIOException(message, Dart_Null());
Dart_ThrowException(socket_io_exception);
Dart_Handle socket_exception =
DartUtils::NewDartSocketException(message, Dart_Null());
Dart_ThrowException(socket_exception);
}
@ -38,9 +38,9 @@ static void ThrowPRException(const char* message) {
const char* error_message = PR_ErrorToString(error_code, PR_LANGUAGE_EN);
OSError os_error_struct(error_code, error_message, OSError::kNSS);
Dart_Handle os_error = DartUtils::NewDartOSError(&os_error_struct);
Dart_Handle socket_io_exception =
DartUtils::NewDartSocketIOException(message, os_error);
Dart_ThrowException(socket_io_exception);
Dart_Handle socket_exception =
DartUtils::NewDartSocketException(message, os_error);
Dart_ThrowException(socket_exception);
}
/*

View file

@ -237,7 +237,7 @@ class _NativeSocket extends NativeFieldWrapperClass1 {
backlog,
v6Only);
if (result is OSError) {
throw new SocketIOException(
throw new SocketException(
"Failed to create server socket", result);
}
if (port != 0) socket.localPort = port;
@ -490,20 +490,20 @@ class _NativeSocket extends NativeFieldWrapperClass1 {
// error objects.
static createError(error, String message) {
if (error is OSError) {
return new SocketIOException(message, error);
return new SocketException(message, error);
} else if (error is List) {
assert(isErrorResponse(error));
switch (error[0]) {
case _ILLEGAL_ARGUMENT_RESPONSE:
return new ArgumentError();
case _OSERROR_RESPONSE:
return new SocketIOException(
return new SocketException(
message, new OSError(error[2], error[1]));
default:
return new Exception("Unknown error");
}
} else {
return new SocketIOException(message);
return new SocketException(message);
}
}

View file

@ -12,7 +12,7 @@ patch class _StdIOUtils {
case _STDIO_HANDLE_TYPE_FILE:
return new _StdStream(new _FileStream.forStdin());
default:
throw new FileIOException("Unsupported stdin type");
throw new FileException("Unsupported stdin type");
}
}
@ -26,14 +26,14 @@ patch class _StdIOUtils {
case _STDIO_HANDLE_TYPE_FILE:
return new _StdSink(new IOSink(new _FileStreamConsumer.fromStdio(fd)));
default:
throw new FileIOException("Unsupported stdin type");
throw new FileException("Unsupported stdin type");
}
}
static int _socketType(nativeSocket) {
var result = _getSocketType(nativeSocket);
if (result is OSError) {
throw new FileIOException("Error retreiving socket type", result);
throw new FileException("Error retreiving socket type", result);
}
return result;
}

View file

@ -37,7 +37,7 @@ class SourceFileProvider {
String source;
try {
source = readAll(uriPathToNative(resourceUri.path));
} on FileIOException catch (ex) {
} on FileException catch (ex) {
throw 'Error: Cannot read "${relativize(cwd, resourceUri, isWindows)}" '
'(${ex.osError}).';
}

View file

@ -71,7 +71,7 @@ class Conversation {
}
static onError(error) {
if (error is HttpParserException) {
if (error is HttpException) {
print('Error: ${error.message}');
} else {
print('Error: ${error}');

View file

@ -87,7 +87,7 @@ void cleanOutputDirectory(Path path) {
// due to invalid result from dir.existsSync() (probably due to race
// conditions).
outputDir.createSync();
} on DirectoryIOException catch (e) {
} on DirectoryException catch (e) {
// Ignore.
}
}
@ -602,7 +602,7 @@ class Dartdoc {
// race conditions).
try {
dir.createSync();
} on DirectoryIOException catch (e) {
} on DirectoryException catch (e) {
// Ignore.
}
}

View file

@ -46,7 +46,7 @@ class ExportMap {
var importsAndExports;
try {
importsAndExports = _importsAndExportsForFile(path, packageRoot);
} on FileIOException catch (_) {
} on FileException catch (_) {
// Ignore unreadable/nonexistent files.
return;
}

View file

@ -173,8 +173,8 @@ and include the results in a bug report on http://dartbug.com/new.
/// Returns the appropriate exit code for [exception], falling back on 1 if no
/// appropriate exit code could be found.
int _chooseExitCode(exception) {
if (exception is HttpException || exception is HttpParserException ||
exception is SocketIOException || exception is PubHttpException) {
if (exception is HttpException || exception is HttpException ||
exception is SocketException || exception is PubHttpException) {
return exit_codes.UNAVAILABLE;
} else if (exception is FormatException) {
return exit_codes.DATA;

View file

@ -156,7 +156,7 @@ class HostedSource extends Source {
fail('Timed out trying to find package "$package" at $url.');
}
if (error is io.SocketIOException) {
if (error is io.SocketException) {
fail('Got socket error trying to find package "$package" at $url.\n'
'${error.osError}');
}

View file

@ -86,7 +86,7 @@ class PubHttpClient extends http.BaseClient {
throw new PubHttpException(response);
});
}).catchError((error) {
if (error is SocketIOException &&
if (error is SocketException &&
error.osError != null) {
if (error.osError.errorCode == 8 ||
error.osError.errorCode == -2 ||

View file

@ -217,7 +217,7 @@ String ensureDir(String dirPath) {
try {
createDir(dirPath);
} on DirectoryIOException catch (ex) {
} on DirectoryException catch (ex) {
// Error 17 means the directory already exists (or 183 on Windows).
if (ex.osError.errorCode == 17 || ex.osError.errorCode == 183) {
log.fine("Got 'already exists' error when creating directory.");

View file

@ -50,9 +50,9 @@ class SafeHttpServer extends StreamView<HttpRequest> implements HttpServer {
// Ignore socket error 104, which is caused by a request being cancelled
// before it writes any headers. There's no reason to care about such
// requests.
if (error is SocketIOException && error.osError.errorCode == 104) return;
if (error is SocketException && error.osError.errorCode == 104) return;
// Ignore any parsing errors, which come from malformed requests.
if (error is HttpParserException) return;
if (error is HttpException) return;
// Manually handle cancelOnError so the above (ignored) errors don't
// cause unsubscription.
if (cancelOnError) subscription.cancel();

View file

@ -529,14 +529,14 @@ void fail(String message) {
bool isUserFacingException(error) {
return error is ApplicationException ||
// TODO(nweiz): clean up this branch when issue 9955 is fixed.
error is DirectoryIOException ||
error is FileIOException ||
error is DirectoryException ||
error is FileException ||
error is HttpException ||
error is HttpParserException ||
error is LinkIOException ||
error is HttpException ||
error is LinkException ||
error is MimeMultipartException ||
error is OSError ||
error is ProcessException ||
error is SocketIOException ||
error is SocketException ||
error is WebSocketException;
}

View file

@ -31,19 +31,26 @@ _exceptionFromResponse(response, String message) {
case _OSERROR_RESPONSE:
var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE],
response[_OSERROR_RESPONSE_ERROR_CODE]);
return new FileIOException(message, err);
return new FileException(message, err);
case _FILE_CLOSED_RESPONSE:
return new FileIOException("File closed");
return new FileException("File closed");
default:
return new Exception("Unknown error");
}
}
/**
* Base class for all IO related exceptions.
*/
abstract class IOException implements Exception {
String toString() => "IOException";
}
/**
* An [OSError] object holds information about an error from the
* operating system.
*/
class OSError implements Error {
class OSError {
/** Constant used to indicate that no OS error code is available. */
static const int noErrorCode = -1;

View file

@ -210,13 +210,13 @@ abstract class Directory implements FileSystemEntity {
}
class DirectoryIOException implements Exception {
const DirectoryIOException([String this.message = "",
class DirectoryException implements IOException {
const DirectoryException([String this.message = "",
String this.path = "",
OSError this.osError = null]);
String toString() {
StringBuffer sb = new StringBuffer();
sb.write("DirectoryIOException");
sb.write("DirectoryException");
if (!message.isEmpty) {
sb.write(": $message");
if (path != null) {

View file

@ -32,7 +32,7 @@ class _Directory implements Directory {
var result = _setCurrent(path);
if (result is ArgumentError) throw result;
if (result is OSError) {
throw new DirectoryIOException(
throw new DirectoryException(
"Setting current working directory failed", path, result);
}
}
@ -56,7 +56,7 @@ class _Directory implements Directory {
}
var result = _exists(_path);
if (result is OSError) {
throw new DirectoryIOException("Exists failed", _path, result);
throw new DirectoryException("Exists failed", _path, result);
}
return (result == 1);
}
@ -155,7 +155,7 @@ class _Directory implements Directory {
if (recursive) return createRecursivelySync();
var result = _create(_path);
if (result is OSError) {
throw new DirectoryIOException("Creation failed", _path, result);
throw new DirectoryException("Creation failed", _path, result);
}
}
@ -179,7 +179,7 @@ class _Directory implements Directory {
}
var result = _createTemp(path);
if (result is OSError) {
throw new DirectoryIOException("Creation of temporary directory failed",
throw new DirectoryException("Creation of temporary directory failed",
_path,
result);
}
@ -209,7 +209,7 @@ class _Directory implements Directory {
}
var result = _delete(_path, recursive);
if (result is OSError) {
throw new DirectoryIOException("Deletion failed", _path, result);
throw new DirectoryException("Deletion failed", _path, result);
}
}
@ -233,7 +233,7 @@ class _Directory implements Directory {
}
var result = _rename(_path, newPath);
if (result is OSError) {
throw new DirectoryIOException("Rename failed", _path, result);
throw new DirectoryException("Rename failed", _path, result);
}
return new Directory(newPath);
}
@ -261,7 +261,7 @@ class _Directory implements Directory {
responsePort.receive((message, replyTo) {
if (message is !List || message[RESPONSE_TYPE] is !int) {
responsePort.close();
controller.addError(new DirectoryIOException("Internal error"));
controller.addError(new DirectoryException("Internal error"));
return;
}
switch (message[RESPONSE_TYPE]) {
@ -287,11 +287,11 @@ class _Directory implements Directory {
var errorPath = message[RESPONSE_PATH];
if (errorPath == null) errorPath = path;
controller.addError(
new DirectoryIOException("Directory listing failed",
new DirectoryException("Directory listing failed",
errorPath,
err));
} else {
controller.addError(new DirectoryIOException("Internal error"));
controller.addError(new DirectoryException("Internal error"));
}
break;
case LIST_DONE:
@ -327,7 +327,7 @@ class _Directory implements Directory {
case _OSERROR_RESPONSE:
var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE],
response[_OSERROR_RESPONSE_ERROR_CODE]);
return new DirectoryIOException(message, _path, err);
return new DirectoryException(message, _path, err);
default:
return new Exception("Unknown error");
}

View file

@ -60,7 +60,7 @@ abstract class File implements FileSystemEntity {
* by [createSync]. Calling [createSync] on an existing file might fail
* if there are restrictive permissions on the file.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
void createSync();
@ -75,7 +75,7 @@ abstract class File implements FileSystemEntity {
* Synchronously delete the file. Only a file or a link to a file
* can be deleted with this method, not a directory or a broken link.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
void deleteSync();
@ -94,7 +94,7 @@ abstract class File implements FileSystemEntity {
/**
* Synchronously get the length of the file.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
int lengthSync();
@ -109,7 +109,7 @@ abstract class File implements FileSystemEntity {
* Get the last-modified time of the file. Throws an exception
* if the file does not exist.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
DateTime lastModifiedSync();
@ -140,7 +140,7 @@ abstract class File implements FileSystemEntity {
*
* See [open] for information on the [mode] argument.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
RandomAccessFile openSync({FileMode mode: FileMode.READ});
@ -153,7 +153,7 @@ abstract class File implements FileSystemEntity {
/**
* Synchronously get the canonical full path corresponding to the file path.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
String fullPathSync();
@ -201,7 +201,7 @@ abstract class File implements FileSystemEntity {
/**
* Synchronously read the entire file contents as a list of bytes.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
List<int> readAsBytesSync();
@ -218,7 +218,7 @@ abstract class File implements FileSystemEntity {
* Synchronously read the entire file contents as a string using the
* given [Encoding].
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
String readAsStringSync({Encoding encoding: Encoding.UTF_8});
@ -235,7 +235,7 @@ abstract class File implements FileSystemEntity {
* Synchronously read the entire file contents as lines of text
* using the given [Encoding].
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
List<String> readAsLinesSync({Encoding encoding: Encoding.UTF_8});
@ -261,7 +261,7 @@ abstract class File implements FileSystemEntity {
* the file if it already exists. In order to append the bytes to an existing
* file, pass [FileMode.APPEND] as the optional mode parameter.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
void writeAsBytesSync(List<int> bytes, {FileMode mode: FileMode.WRITE});
@ -291,7 +291,7 @@ abstract class File implements FileSystemEntity {
* to an existing file, pass [FileMode.APPEND] as the optional mode
* parameter.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
void writeAsStringSync(String contents,
{FileMode mode: FileMode.WRITE,
@ -319,7 +319,7 @@ abstract class RandomAccessFile {
/**
* Synchronously closes the file.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
void closeSync();
@ -333,7 +333,7 @@ abstract class RandomAccessFile {
* Synchronously reads a single byte from the file. If end-of-file
* has been reached -1 is returned.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
int readByteSync();
@ -346,7 +346,7 @@ abstract class RandomAccessFile {
* Synchronously reads a maximum of [bytes] bytes from a file and
* returns the result in a list of bytes.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
List<int> readSync(int bytes);
@ -368,7 +368,7 @@ abstract class RandomAccessFile {
* read into [buffer], otherwise up to [buffer.length]. If [end] == [start]
* nothing happends.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
int readIntoSync(List<int> buffer, [int start, int end]);
@ -383,7 +383,7 @@ abstract class RandomAccessFile {
* Synchronously writes a single byte to the file. Returns the
* number of bytes successfully written.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
int writeByteSync(int value);
@ -403,7 +403,7 @@ abstract class RandomAccessFile {
* start from index 0. If [end] is omitted, it will write to the end of
* [buffer].
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
void writeFromSync(List<int> buffer, [int start, int end]);
@ -419,7 +419,7 @@ abstract class RandomAccessFile {
* Synchronously writes a single string to the file using the given
* [Encoding].
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
void writeStringSync(String string,
{Encoding encoding: Encoding.UTF_8});
@ -433,7 +433,7 @@ abstract class RandomAccessFile {
/**
* Synchronously gets the current byte position in the file.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
int positionSync();
@ -447,7 +447,7 @@ abstract class RandomAccessFile {
/**
* Synchronously sets the byte position in the file.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
void setPositionSync(int position);
@ -461,7 +461,7 @@ abstract class RandomAccessFile {
/**
* Synchronously truncates (or extends) the file to [length] bytes.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
void truncateSync(int length);
@ -474,7 +474,7 @@ abstract class RandomAccessFile {
/**
* Synchronously gets the length of the file.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
int lengthSync();
@ -488,7 +488,7 @@ abstract class RandomAccessFile {
/**
* Synchronously flushes the contents of the file to disk.
*
* Throws a [FileIOException] if the operation fails.
* Throws a [FileException] if the operation fails.
*/
void flushSync();
@ -504,12 +504,12 @@ abstract class RandomAccessFile {
}
class FileIOException implements Exception {
const FileIOException([String this.message = "",
class FileException implements IOException {
const FileException([String this.message = "",
OSError this.osError = null]);
String toString() {
StringBuffer sb = new StringBuffer();
sb.write("FileIOException");
sb.write("FileException");
if (!message.isEmpty) {
sb.write(": $message");
if (osError != null) {

View file

@ -393,7 +393,7 @@ class _File implements File {
if (mode != FileMode.READ &&
mode != FileMode.WRITE &&
mode != FileMode.APPEND) {
throw new FileIOException("Unknown file mode. Use FileMode.READ, "
throw new FileException("Unknown file mode. Use FileMode.READ, "
"FileMode.WRITE or FileMode.APPEND.");
}
var id = _open(_path, mode._mode);
@ -406,7 +406,7 @@ class _File implements File {
static RandomAccessFile _openStdioSync(int fd) {
var id = _openStdio(fd);
if (id == 0) {
throw new FileIOException("Cannot open stdio file for: $fd");
throw new FileException("Cannot open stdio file for: $fd");
}
return new _RandomAccessFile(id, "");
}
@ -442,7 +442,7 @@ class _File implements File {
Encoding encoding: Encoding.UTF_8}) {
if (mode != FileMode.WRITE &&
mode != FileMode.APPEND) {
throw new FileIOException(
throw new FileException(
"Wrong FileMode. Use FileMode.WRITE or FileMode.APPEND");
}
var consumer = new _FileStreamConsumer(this, mode);
@ -559,7 +559,7 @@ class _File implements File {
static throwIfError(Object result, String msg) {
if (result is OSError) {
throw new FileIOException(msg, result);
throw new FileException(msg, result);
}
}
@ -586,7 +586,7 @@ class _RandomAccessFile implements RandomAccessFile {
_id = result;
return this;
} else {
throw new FileIOException("Cannot close file '$_path'");
throw new FileException("Cannot close file '$_path'");
}
});
}
@ -597,7 +597,7 @@ class _RandomAccessFile implements RandomAccessFile {
_checkNotClosed();
var id = _close(_id);
if (id == -1) {
throw new FileIOException("Cannot close file '$_path'");
throw new FileException("Cannot close file '$_path'");
}
_id = id;
}
@ -623,7 +623,7 @@ class _RandomAccessFile implements RandomAccessFile {
_checkNotClosed();
var result = _readByte(_id);
if (result is OSError) {
throw new FileIOException("readByte failed for file '$_path'", result);
throw new FileException("readByte failed for file '$_path'", result);
}
return result;
}
@ -631,7 +631,7 @@ class _RandomAccessFile implements RandomAccessFile {
Future<List<int>> read(int bytes) {
_ensureFileService();
if (bytes is !int) {
return new Future.error(new FileIOException(
return new Future.error(new FileException(
"Invalid arguments to read for file '$_path'"));
}
if (closed) return _closedException();
@ -653,12 +653,12 @@ class _RandomAccessFile implements RandomAccessFile {
List<int> readSync(int bytes) {
_checkNotClosed();
if (bytes is !int) {
throw new FileIOException(
throw new FileException(
"Invalid arguments to readSync for file '$_path'");
}
var result = _read(_id, bytes);
if (result is OSError) {
throw new FileIOException("readSync failed for file '$_path'",
throw new FileException("readSync failed for file '$_path'",
result);
}
return result;
@ -669,7 +669,7 @@ class _RandomAccessFile implements RandomAccessFile {
if (buffer is !List ||
(start != null && start is !int) ||
(end != null && end is !int)) {
return new Future.error(new FileIOException(
return new Future.error(new FileException(
"Invalid arguments to readInto for file '$_path'"));
};
if (closed) return _closedException();
@ -706,7 +706,7 @@ class _RandomAccessFile implements RandomAccessFile {
if (buffer is !List ||
(start != null && start is !int) ||
(end != null && end is !int)) {
throw new FileIOException(
throw new FileException(
"Invalid arguments to readInto for file '$_path'");
}
if (start == null) start = 0;
@ -715,7 +715,7 @@ class _RandomAccessFile implements RandomAccessFile {
_checkReadWriteListArguments(buffer.length, start, end);
var result = _readInto(_id, buffer, start, end);
if (result is OSError) {
throw new FileIOException("readInto failed for file '$_path'",
throw new FileException("readInto failed for file '$_path'",
result);
}
return result;
@ -724,7 +724,7 @@ class _RandomAccessFile implements RandomAccessFile {
Future<RandomAccessFile> writeByte(int value) {
_ensureFileService();
if (value is !int) {
return new Future.error(new FileIOException(
return new Future.error(new FileException(
"Invalid argument to writeByte for file '$_path'"));
}
if (closed) return _closedException();
@ -746,12 +746,12 @@ class _RandomAccessFile implements RandomAccessFile {
int writeByteSync(int value) {
_checkNotClosed();
if (value is !int) {
throw new FileIOException(
throw new FileException(
"Invalid argument to writeByte for file '$_path'");
}
var result = _writeByte(_id, value);
if (result is OSError) {
throw new FileIOException("writeByte failed for file '$_path'",
throw new FileException("writeByte failed for file '$_path'",
result);
}
return result;
@ -762,7 +762,7 @@ class _RandomAccessFile implements RandomAccessFile {
if ((buffer is !List && buffer is !ByteData) ||
(start != null && start is !int) ||
(end != null && end is !int)) {
return new Future.error(new FileIOException(
return new Future.error(new FileException(
"Invalid arguments to writeFrom for file '$_path'"));
}
@ -797,7 +797,7 @@ class _RandomAccessFile implements RandomAccessFile {
if (buffer is !List ||
(start != null && start is !int) ||
(end != null && end is !int)) {
throw new FileIOException(
throw new FileException(
"Invalid arguments to writeFrom for file '$_path'");
}
if (start == null) start = 0;
@ -811,14 +811,14 @@ class _RandomAccessFile implements RandomAccessFile {
bufferAndStart.start,
end - (start - bufferAndStart.start));
if (result is OSError) {
throw new FileIOException("writeFrom failed for file '$_path'", result);
throw new FileException("writeFrom failed for file '$_path'", result);
}
}
Future<RandomAccessFile> writeString(String string,
{Encoding encoding: Encoding.UTF_8}) {
if (encoding is! Encoding) {
return new Future.error(new FileIOException(
return new Future.error(new FileException(
"Invalid encoding in writeString: $encoding"));
}
var data = _encodeString(string, encoding);
@ -827,7 +827,7 @@ class _RandomAccessFile implements RandomAccessFile {
void writeStringSync(String string, {Encoding encoding: Encoding.UTF_8}) {
if (encoding is! Encoding) {
throw new FileIOException(
throw new FileException(
"Invalid encoding in writeStringSync: $encoding");
}
var data = _encodeString(string, encoding);
@ -855,7 +855,7 @@ class _RandomAccessFile implements RandomAccessFile {
_checkNotClosed();
var result = _position(_id);
if (result is OSError) {
throw new FileIOException("position failed for file '$_path'", result);
throw new FileException("position failed for file '$_path'", result);
}
return result;
}
@ -882,7 +882,7 @@ class _RandomAccessFile implements RandomAccessFile {
_checkNotClosed();
var result = _setPosition(_id, position);
if (result is OSError) {
throw new FileIOException("setPosition failed for file '$_path'", result);
throw new FileException("setPosition failed for file '$_path'", result);
}
}
@ -908,7 +908,7 @@ class _RandomAccessFile implements RandomAccessFile {
_checkNotClosed();
var result = _truncate(_id, length);
if (result is OSError) {
throw new FileIOException("truncate failed for file '$_path'", result);
throw new FileException("truncate failed for file '$_path'", result);
}
}
@ -933,7 +933,7 @@ class _RandomAccessFile implements RandomAccessFile {
_checkNotClosed();
var result = _length(_id);
if (result is OSError) {
throw new FileIOException("length failed for file '$_path'", result);
throw new FileException("length failed for file '$_path'", result);
}
return result;
}
@ -959,7 +959,7 @@ class _RandomAccessFile implements RandomAccessFile {
_checkNotClosed();
var result = _flush(_id);
if (result is OSError) {
throw new FileIOException("flush failed for file '$_path'", result);
throw new FileException("flush failed for file '$_path'", result);
}
}
@ -975,12 +975,12 @@ class _RandomAccessFile implements RandomAccessFile {
void _checkNotClosed() {
if (closed) {
throw new FileIOException("File closed '$_path'");
throw new FileException("File closed '$_path'");
}
}
Future _closedException() {
return new Future.error(new FileIOException("File closed '$_path'"));
return new Future.error(new FileException("File closed '$_path'"));
}
final String _path;

View file

@ -371,7 +371,7 @@ abstract class FileSystemEntity {
static _throwIfError(Object result, String msg) {
if (result is OSError) {
throw new FileIOException(msg, result);
throw new FileException(msg, result);
} else if (result is ArgumentError) {
throw result;
}

View file

@ -1373,27 +1373,21 @@ abstract class DetachedSocket {
}
class HttpException implements Exception {
const HttpException([String this.message = ""]);
String toString() => "HttpException: $message";
class HttpException implements IOException {
final String message;
const HttpException([String this.message = ""]);
String toString() => "HttpException: $message";
}
class RedirectException extends HttpException {
const RedirectException(String message,
List<RedirectInfo> this.redirects) : super(message);
class RedirectException implements HttpException {
final String message;
final List<RedirectInfo> redirects;
}
class RedirectLimitExceededException extends RedirectException {
const RedirectLimitExceededException(List<RedirectInfo> redirects)
: super("Redirect limit exceeded", redirects);
}
class RedirectLoopException extends RedirectException {
const RedirectLoopException(List<RedirectInfo> redirects)
: super("Redirect loop detected", redirects);
const RedirectException(String this.message,
List<RedirectInfo> this.redirects);
String toString() => "RedirectException: $message";
}

View file

@ -216,7 +216,7 @@ class _HttpClientResponse
for (var redirect in redirects) {
if (redirect.location == url) {
return new Future.error(
new RedirectLoopException(redirects));
new RedirectException("Redirect loop detected", redirects));
}
}
}
@ -573,7 +573,7 @@ class _HttpOutboundConsumer implements StreamConsumer {
},
onError: (error) {
_socketError = true;
if (error is SocketIOException &&
if (error is SocketException &&
_outbound is HttpResponse) {
_cancel();
_done();
@ -897,7 +897,8 @@ class _HttpClientRequest extends _HttpOutboundMessage<HttpClientResponse>
// End with exception, too many redirects.
future = response.drain()
.then((_) => new Future.error(
new RedirectLimitExceededException(response.redirects)));
new RedirectException("Redirect limit exceeded",
response.redirects)));
}
} else if (response._shouldAuthenticateProxy) {
future = response._authenticate(true);
@ -1233,10 +1234,8 @@ class _HttpClientConnection {
})
// If we see a state error, we failed to get the 'first'
// element.
// Transform the error to a HttpParserException, for
// consistency.
.catchError((error) {
throw new HttpParserException(
throw new HttpException(
"Connection closed before data was received");
}, test: (error) => error is StateError)
.catchError((error) {

View file

@ -273,10 +273,10 @@ class _HttpParser
assert(!_parserCalled);
_parserCalled = true;
if (_state == _State.CLOSED) {
throw new HttpParserException("Data on closed connection");
throw new HttpException("Data on closed connection");
}
if (_state == _State.FAILURE) {
throw new HttpParserException("Data on failed connection");
throw new HttpException("Data on failed connection");
}
while (_buffer != null &&
_index < _buffer.length &&
@ -298,11 +298,11 @@ class _HttpParser
} else {
// Start parsing method.
if (!_isTokenChar(byte)) {
throw new HttpParserException("Invalid request method");
throw new HttpException("Invalid request method");
}
_method_or_status_code.add(byte);
if (!_requestParser) {
throw new HttpParserException("Invalid response line");
throw new HttpException("Invalid response line");
}
_state = _State.REQUEST_LINE_METHOD;
}
@ -319,7 +319,7 @@ class _HttpParser
// method anymore.
_httpVersionIndex++;
if (_requestParser) {
throw new HttpParserException("Invalid request line");
throw new HttpException("Invalid request line");
}
_state = _State.RESPONSE_HTTP_VERSION;
} else {
@ -333,7 +333,7 @@ class _HttpParser
_method_or_status_code.add(byte);
_httpVersion = _HttpVersion.UNDETERMINED;
if (!_requestParser) {
throw new HttpParserException("Invalid response line");
throw new HttpException("Invalid response line");
}
_state = _State.REQUEST_LINE_METHOD;
}
@ -362,7 +362,7 @@ class _HttpParser
// HTTP version parsed.
_state = _State.RESPONSE_LINE_STATUS_CODE;
} else {
throw new HttpParserException("Invalid response line");
throw new HttpException("Invalid response line");
}
break;
@ -371,7 +371,7 @@ class _HttpParser
_state = _State.REQUEST_LINE_URI;
} else {
if (_Const.SEPARATORS_AND_CR_LF.indexOf(byte) != -1) {
throw new HttpParserException("Invalid request method");
throw new HttpException("Invalid request method");
}
_method_or_status_code.add(byte);
}
@ -380,13 +380,13 @@ class _HttpParser
case _State.REQUEST_LINE_URI:
if (byte == _CharCode.SP) {
if (_uri_or_reason_phrase.length == 0) {
throw new HttpParserException("Invalid request URI");
throw new HttpException("Invalid request URI");
}
_state = _State.REQUEST_LINE_HTTP_VERSION;
_httpVersionIndex = 0;
} else {
if (byte == _CharCode.CR || byte == _CharCode.LF) {
throw new HttpParserException("Invalid request URI");
throw new HttpException("Invalid request URI");
}
_uri_or_reason_phrase.add(byte);
}
@ -408,7 +408,7 @@ class _HttpParser
_persistentConnection = false;
_httpVersionIndex++;
} else {
throw new HttpParserException("Invalid response line");
throw new HttpException("Invalid response line");
}
} else {
_expect(byte, _CharCode.CR);
@ -425,12 +425,12 @@ class _HttpParser
case _State.RESPONSE_LINE_STATUS_CODE:
if (byte == _CharCode.SP) {
if (_method_or_status_code.length != 3) {
throw new HttpParserException("Invalid response status code");
throw new HttpException("Invalid response status code");
}
_state = _State.RESPONSE_LINE_REASON_PHRASE;
} else {
if (byte < 0x30 && 0x39 < byte) {
throw new HttpParserException("Invalid response status code");
throw new HttpException("Invalid response status code");
} else {
_method_or_status_code.add(byte);
}
@ -442,7 +442,7 @@ class _HttpParser
_state = _State.RESPONSE_LINE_ENDING;
} else {
if (byte == _CharCode.CR || byte == _CharCode.LF) {
throw new HttpParserException("Invalid response reason phrase");
throw new HttpException("Invalid response reason phrase");
}
_uri_or_reason_phrase.add(byte);
}
@ -454,7 +454,7 @@ class _HttpParser
_statusCode = int.parse(
new String.fromCharCodes(_method_or_status_code));
if (_statusCode < 100 || _statusCode > 599) {
throw new HttpParserException("Invalid response status code");
throw new HttpException("Invalid response status code");
} else {
// Check whether this response will never have a body.
_noMessageBody = _statusCode <= 199 || _statusCode == 204 ||
@ -479,7 +479,7 @@ class _HttpParser
_state = _State.HEADER_VALUE_START;
} else {
if (!_isTokenChar(byte)) {
throw new HttpParserException("Invalid header field name");
throw new HttpException("Invalid header field name");
}
_headerField.add(_toLowerCase(byte));
}
@ -728,8 +728,7 @@ class _HttpParser
!(_state == _State.START && !_requestParser) &&
!(_state == _State.BODY && !_chunked && _transferLength == -1)) {
_bodyController.addError(
new HttpParserException(
"Connection closed while receiving data"));
new HttpException("Connection closed while receiving data"));
}
_closeIncoming(true);
_controller.close();
@ -738,7 +737,7 @@ class _HttpParser
// If the connection is idle the HTTP stream is closed.
if (_state == _State.START) {
if (!_requestParser) {
error(new HttpParserException(
error(new HttpException(
"Connection closed before full header was received"));
}
_controller.close();
@ -754,7 +753,7 @@ class _HttpParser
_state = _State.FAILURE;
// Report the error through the error callback if any. Otherwise
// throw the error.
error(new HttpParserException(
error(new HttpException(
"Connection closed before full header was received"));
_controller.close();
return;
@ -766,7 +765,7 @@ class _HttpParser
_state = _State.FAILURE;
// Report the error through the error callback if any. Otherwise
// throw the error.
error(new HttpParserException(
error(new HttpException(
"Connection closed before full body was received"));
}
_controller.close();
@ -863,7 +862,7 @@ class _HttpParser
int _expect(int val1, int val2) {
if (val1 != val2) {
throw new HttpParserException("Failed to parse HTTP");
throw new HttpException("Failed to parse HTTP");
}
}
@ -875,7 +874,7 @@ class _HttpParser
} else if (0x61 <= byte && byte <= 0x66) {
return byte - 0x61 + 10; // a - f
} else {
throw new HttpParserException("Failed to parse HTTP");
throw new HttpException("Failed to parse HTTP");
}
}
@ -988,10 +987,3 @@ class _HttpParser
StreamController<_HttpIncoming> _controller;
StreamController<List<int>> _bodyController;
}
class HttpParserException implements Exception {
const HttpParserException([String this.message = ""]);
String toString() => "HttpParserException: $message";
final String message;
}

View file

@ -68,7 +68,7 @@ abstract class Link implements FileSystemEntity {
* the link when it has been deleted. This does not delete, or otherwise
* affect, the target of the link. It also works on broken links, but if
* the link does not exist or is not actually a link, it completes the
* future with a LinkIOException.
* future with a LinkException.
*/
Future<Link> delete();
@ -76,7 +76,7 @@ abstract class Link implements FileSystemEntity {
* Synchronously deletes the link. This does not delete, or otherwise
* affect, the target of the link. It also works on broken links, but if
* the link does not exist or is not actually a link, it throws a
* LinkIOException.
* LinkException.
*/
void deleteSync();
@ -88,7 +88,7 @@ abstract class Link implements FileSystemEntity {
* directory containing the link.
*
* If the link does not exist, or is not a link, the future completes with
* a LinkIOException.
* a LinkException.
*/
Future<String> target();
@ -98,7 +98,7 @@ abstract class Link implements FileSystemEntity {
* If the returned target is a relative path, it is relative to the
* directory containing the link.
*
* If the link does not exist, or is not a link, throws a LinkIOException.
* If the link does not exist, or is not a link, throws a LinkException.
*/
String targetSync();
}
@ -213,7 +213,7 @@ class _Link extends FileSystemEntity implements Link {
static throwIfError(Object result, String msg) {
if (result is OSError) {
throw new LinkIOException(msg, result);
throw new LinkException(msg, result);
}
}
@ -235,7 +235,7 @@ class _Link extends FileSystemEntity implements Link {
case _OSERROR_RESPONSE:
var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE],
response[_OSERROR_RESPONSE_ERROR_CODE]);
return new LinkIOException(message, err);
return new LinkException(message, err);
default:
return new Exception("Unknown error");
}
@ -243,13 +243,13 @@ class _Link extends FileSystemEntity implements Link {
}
class LinkIOException implements Exception {
const LinkIOException([String this.message = "",
class LinkException implements IOException {
const LinkException([String this.message = "",
String this.path = "",
OSError this.osError = null]);
String toString() {
StringBuffer sb = new StringBuffer();
sb.write("LinkIOException");
sb.write("LinkException");
if (!message.isEmpty) {
sb.write(": $message");
if (path != null) {

View file

@ -398,7 +398,7 @@ class MimeMultipartTransformer
}
class MimeMultipartException implements Exception {
class MimeMultipartException implements IOException {
const MimeMultipartException([String this.message = ""]);
String toString() => "MimeMultipartException: $message";
final String message;

View file

@ -255,7 +255,7 @@ class ProcessSignal {
}
class ProcessException implements Exception {
class ProcessException implements IOException {
const ProcessException(String this.executable,
List<String> this.arguments,
[String this.message = "",

View file

@ -614,7 +614,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
List<int> read([int len]) {
if (_closedRead) {
throw new SocketIOException("Reading from a closed socket");
throw new SocketException("Reading from a closed socket");
}
if (_status != CONNECTED) {
return null;
@ -663,7 +663,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
// up handlers to flush the pipeline when possible.
int write(List<int> data, [int offset, int bytes]) {
if (_closedWrite) {
_controller.addError(new SocketIOException("Writing to a closed socket"));
_controller.addError(new SocketException("Writing to a closed socket"));
return 0;
}
if (_status != CONNECTED) return 0;
@ -750,7 +750,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
} else {
if (_status != CONNECTED) {
// Cannot happen.
throw new SocketIOException("Internal SocketIO Error");
throw new SocketException("Internal SocketIO Error");
}
try {
_readEncryptedData();
@ -783,12 +783,12 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
void _reportError(e, String message) {
// TODO(whesse): Call _reportError from all internal functions that throw.
if (e is SocketIOException) {
e = new SocketIOException('$message (${e.message})', e.osError);
if (e is SocketException) {
e = new SocketException('$message (${e.message})', e.osError);
} else if (e is OSError) {
e = new SocketIOException(message, e);
e = new SocketException(message, e);
} else {
e = new SocketIOException('$message (${e.toString()})', null);
e = new SocketException('$message (${e.toString()})', null);
}
if (_connectPending) {
_handshakeComplete.completeError(e);
@ -811,7 +811,7 @@ class _RawSecureSocket extends Stream<RawSocketEvent>
}
} else if (_status == HANDSHAKE) {
_reportError(
new SocketIOException('Connection terminated during handshake'),
new SocketException('Connection terminated during handshake'),
'handshake error');
}
}

View file

@ -409,12 +409,12 @@ abstract class Socket implements Stream<List<int>>, IOSink {
}
class SocketIOException implements Exception {
const SocketIOException([String this.message = "",
OSError this.osError = null]);
class SocketException implements IOException {
const SocketException([String this.message = "",
OSError this.osError = null]);
String toString() {
StringBuffer sb = new StringBuffer();
sb.write("SocketIOException");
sb.write("SocketException");
if (!message.isEmpty) {
sb.write(": $message");
if (osError != null) {

View file

@ -153,7 +153,7 @@ abstract class WebSocket implements Stream, StreamSink {
}
class WebSocketException implements Exception {
class WebSocketException implements IOException {
const WebSocketException([String this.message = ""]);
String toString() => "WebSocketException: $message";
final String message;

View file

@ -15,7 +15,7 @@ Directory tempDir() {
bool checkCreateInNonExistentFileException(e) {
Expect.isTrue(e is DirectoryIOException);
Expect.isTrue(e is DirectoryException);
Expect.isTrue(e.osError != null);
Expect.isTrue(e.toString().indexOf("Creation failed") != -1);
if (Platform.operatingSystem == "linux") {
@ -43,7 +43,7 @@ void testCreateInNonExistent(Directory temp, Function done) {
bool checkCreateTempInNonExistentFileException(e) {
Expect.isTrue(e is DirectoryIOException);
Expect.isTrue(e is DirectoryException);
Expect.isTrue(e.osError != null);
if (Platform.operatingSystem == "linux") {
Expect.equals(2, e.osError.errorCode);
@ -70,7 +70,7 @@ void testCreateTempInNonExistent(Directory temp, Function done) {
bool checkDeleteNonExistentFileException(e) {
Expect.isTrue(e is DirectoryIOException);
Expect.isTrue(e is DirectoryException);
Expect.isTrue(e.osError != null);
// File not not found has error code 2 on all supported platforms.
Expect.equals(2, e.osError.errorCode);
@ -92,7 +92,7 @@ void testDeleteNonExistent(Directory temp, Function done) {
bool checkDeleteRecursivelyNonExistentFileException(e) {
Expect.isTrue(e is DirectoryIOException);
Expect.isTrue(e is DirectoryException);
Expect.isTrue(e.osError != null);
Expect.isTrue(e.toString().indexOf("Deletion failed") != -1);
// File not not found has error code 2 on all supported platforms.
@ -115,7 +115,7 @@ void testDeleteRecursivelyNonExistent(Directory temp, Function done) {
bool checkListNonExistentFileException(e) {
Expect.isTrue(e is DirectoryIOException);
Expect.isTrue(e is DirectoryException);
Expect.isTrue(e.osError != null);
Expect.isTrue(e.toString().indexOf("Directory listing failed") != -1);
if (Platform.operatingSystem == "linux") {
@ -137,7 +137,7 @@ bool checkAsyncListNonExistentFileException(error) {
void testListNonExistent(Directory temp, Function done) {
Directory nonExistent = new Directory("${temp.path}/nonExistent");
Expect.throws(() => nonExistent.listSync(), (e) => e is DirectoryIOException);
Expect.throws(() => nonExistent.listSync(), (e) => e is DirectoryException);
nonExistent.list().listen(
(_) => Expect.fail("listing should not succeed"),
onError: (e) {
@ -151,11 +151,11 @@ void testRenameNonExistent(Directory temp, Function done) {
Directory nonExistent = new Directory("${temp.path}/nonExistent");
var newPath = "${temp.path}/nonExistent2";
Expect.throws(() => nonExistent.renameSync(newPath),
(e) => e is DirectoryIOException);
(e) => e is DirectoryException);
var renameDone = nonExistent.rename(newPath);
renameDone.then((ignore) => Expect.fail('rename non existent'))
.catchError((error) {
Expect.isTrue(error is DirectoryIOException);
Expect.isTrue(error is DirectoryException);
done();
});
}
@ -167,11 +167,11 @@ void testRenameFileAsDirectory(Directory temp, Function done) {
f.createSync();
var d = new Directory(f.path);
Expect.throws(() => d.renameSync(newPath),
(e) => e is DirectoryIOException);
(e) => e is DirectoryException);
var renameDone = d.rename(newPath);
renameDone.then((ignore) => Expect.fail('rename file as directory'))
.catchError((error) {
Expect.isTrue(error is DirectoryIOException);
Expect.isTrue(error is DirectoryException);
done();
});
}
@ -183,11 +183,11 @@ testRenameOverwriteFile(Directory temp, Function done) {
var fileName = '${temp.path}/x';
new File(fileName).createSync();
Expect.throws(() => temp1.renameSync(fileName),
(e) => e is DirectoryIOException);
(e) => e is DirectoryException);
var renameDone = temp1.rename(fileName);
renameDone.then((ignore) => Expect.fail('rename dir overwrite file'))
.catchError((error) {
Expect.isTrue(error is DirectoryIOException);
Expect.isTrue(error is DirectoryException);
temp1.deleteSync(recursive: true);
done();
});

View file

@ -15,9 +15,9 @@ void testListNonExistent() {
var keepAlive = new ReceivePort();
new Directory("").createTemp().then((d) {
d.delete().then((ignore) {
Expect.throws(() => d.listSync(), (e) => e is DirectoryIOException);
Expect.throws(() => d.listSync(), (e) => e is DirectoryException);
Expect.throws(() => d.listSync(recursive: true),
(e) => e is DirectoryIOException);
(e) => e is DirectoryException);
keepAlive.close();
});
});
@ -38,9 +38,9 @@ void testListTooLongName() {
}
var long = new Directory("${buffer.toString()}");
Expect.throws(() => long.listSync(),
(e) => e is DirectoryIOException);
(e) => e is DirectoryException);
Expect.throws(() => long.listSync(recursive: true),
(e) => e is DirectoryIOException);
(e) => e is DirectoryException);
d.deleteSync(recursive: true);
keepAlive.close();
});

View file

@ -90,7 +90,7 @@ class DirectoryTest {
stream.listen(
(_) => Expect.fail("Listing of non-existing directory should fail"),
onError: (error) {
Expect.isTrue(error is DirectoryIOException);
Expect.isTrue(error is DirectoryException);
});
}
new Directory("").createTemp().then((d) {
@ -109,7 +109,7 @@ class DirectoryTest {
stream.listen(
(_) => Expect.fail("Listing of non-existing directory should fail"),
onError: (error) {
Expect.isTrue(error is DirectoryIOException);
Expect.isTrue(error is DirectoryException);
if (++errors == 2) {
d.delete(recursive: true).then((_) {
port.close();
@ -140,7 +140,7 @@ class DirectoryTest {
future.then((ignore) {
Expect.fail("Deletion of non-existing directory should fail");
}).catchError((error) {
Expect.isTrue(error is DirectoryIOException);
Expect.isTrue(error is DirectoryException);
});
}
@ -168,7 +168,7 @@ class DirectoryTest {
var long = new Directory("${buffer.toString()}");
var errors = 0;
onError(error) {
Expect.isTrue(error is DirectoryIOException);
Expect.isTrue(error is DirectoryException);
if (++errors == 2) {
d.delete(recursive: true).then((ignore) => port.close());
}
@ -473,7 +473,7 @@ testCreateTempErrorSync() {
var location = illegalTempDirectoryLocation();
if (location != null) {
Expect.throws(new Directory(location).createTempSync,
(e) => e is DirectoryIOException);
(e) => e is DirectoryException);
}
}
@ -537,7 +537,7 @@ testCreateDirExistingFileSync() {
file.createSync();
Expect.isTrue(file.existsSync());
Expect.throws(new Directory(path).createSync,
(e) => e is DirectoryIOException);
(e) => e is DirectoryException);
temp.deleteSync(recursive: true);
}
@ -554,7 +554,7 @@ testCreateDirExistingFile() {
subDir.create()
.then((_) { Expect.fail("dir create should fail on existing file"); })
.catchError((error) {
Expect.isTrue(error is DirectoryIOException);
Expect.isTrue(error is DirectoryException);
temp.delete(recursive: true).then((_) {
port.close();
});

View file

@ -14,7 +14,7 @@ Directory tempDir() {
bool checkNonExistentFileException(e, str) {
Expect.isTrue(e is FileIOException);
Expect.isTrue(e is FileException);
Expect.isTrue(e.osError != null);
Expect.isTrue(e.toString().indexOf(str) != -1);
// File not not found has error code 2 on all supported platforms.
@ -105,7 +105,7 @@ void testLengthNonExistent() {
bool checkCreateInNonExistentDirectoryException(e) {
Expect.isTrue(e is FileIOException);
Expect.isTrue(e is FileException);
Expect.isTrue(e.osError != null);
Expect.isTrue(e.toString().indexOf("Cannot create file") != -1);
if (Platform.operatingSystem == "linux") {
@ -141,7 +141,7 @@ void testCreateInNonExistentDirectory() {
}
bool checkFullPathOnNonExistentDirectoryException(e) {
Expect.isTrue(e is FileIOException);
Expect.isTrue(e is FileException);
Expect.isTrue(e.osError != null);
Expect.isTrue(e.toString().indexOf("Cannot retrieve full path") != -1);
// File not not found has error code 2 on all supported platforms.
@ -235,7 +235,7 @@ testReadAsLinesNonExistent() {
}
bool checkWriteReadOnlyFileException(e) {
Expect.isTrue(e is FileIOException);
Expect.isTrue(e is FileException);
Expect.isTrue(e.osError != null);
Expect.isTrue(e.osError.errorCode != OSError.noErrorCode);
return true;
@ -313,7 +313,7 @@ testTruncateReadOnlyFile() {
}
bool checkFileClosedException(e) {
Expect.isTrue(e is FileIOException);
Expect.isTrue(e is FileException);
Expect.isTrue(e.toString().indexOf("File closed") != -1);
Expect.isTrue(e.osError == null);
return true;
@ -405,7 +405,7 @@ testRepeatedlyCloseFile() {
var closeFuture = openedFile.close();
closeFuture.then((ignore) => null)
.catchError((error) {
Expect.isTrue(error is FileIOException);
Expect.isTrue(error is FileException);
port.send(null);
});
});
@ -417,7 +417,7 @@ testRepeatedlyCloseFileSync() {
var openedFile = file.openSync();
openedFile.closeSync();
Expect.throws(openedFile.closeSync,
(e) => e is FileIOException);
(e) => e is FileException);
port.send(null);
});
}
@ -427,7 +427,7 @@ testReadSyncBigInt() {
var bigint = 100000000000000000000000000000000000000000;
var openedFile = file.openSync();
Expect.throws(() => openedFile.readSync(bigint),
(e) => e is FileIOException);
(e) => e is FileException);
openedFile.closeSync();
port.send(null);
});
@ -438,7 +438,7 @@ testReadSyncClosedFile() {
var openedFile = file.openSync();
openedFile.closeSync();
Expect.throws(() => openedFile.readSync(1),
(e) => e is FileIOException);
(e) => e is FileException);
port.send(null);
});
}

View file

@ -15,7 +15,7 @@ void testReadInvalidArgs(arg) {
file.readSync(arg);
Expect.fail('exception expected');
} catch (e) {
Expect.isTrue(e is FileIOException);
Expect.isTrue(e is FileException);
Expect.isTrue(e.toString().contains('Invalid arguments'));
}
@ -25,7 +25,7 @@ void testReadInvalidArgs(arg) {
Expect.fail('exception expected');
}).catchError((error) {
errors++;
Expect.isTrue(error is FileIOException);
Expect.isTrue(error is FileException);
Expect.isTrue(error.toString().contains('Invalid arguments'));
file.close().then((ignore) {
Expect.equals(1, errors);
@ -42,7 +42,7 @@ void testReadIntoInvalidArgs(buffer, start, end) {
file.readIntoSync(buffer, start, end);
Expect.fail('exception expected');
} catch (e) {
Expect.isTrue(e is FileIOException);
Expect.isTrue(e is FileException);
Expect.isTrue(e.toString().contains('Invalid arguments'));
}
@ -52,7 +52,7 @@ void testReadIntoInvalidArgs(buffer, start, end) {
Expect.fail('exception expected');
}).catchError((error) {
errors++;
Expect.isTrue(error is FileIOException);
Expect.isTrue(error is FileException);
Expect.isTrue(error.toString().contains('Invalid arguments'));
file.close().then((ignore) {
Expect.equals(1, errors);
@ -69,7 +69,7 @@ void testWriteByteInvalidArgs(value) {
file.writeByteSync(value);
Expect.fail('exception expected');
} catch (e) {
Expect.isTrue(e is FileIOException);
Expect.isTrue(e is FileException);
Expect.isTrue(e.toString().contains('Invalid argument'));
}
@ -77,7 +77,7 @@ void testWriteByteInvalidArgs(value) {
writeByteFuture.then((ignore) {
Expect.fail('exception expected');
}).catchError((error) {
Expect.isTrue(error is FileIOException);
Expect.isTrue(error is FileException);
Expect.isTrue(error.toString().contains('Invalid argument'));
file.close().then((ignore) {
port.close();
@ -93,7 +93,7 @@ void testWriteFromInvalidArgs(buffer, start, end) {
file.writeFromSync(buffer, start, end);
Expect.fail('exception expected');
} catch (e) {
Expect.isTrue(e is FileIOException);
Expect.isTrue(e is FileException);
Expect.isTrue(e.toString().contains('Invalid arguments'));
}
@ -101,7 +101,7 @@ void testWriteFromInvalidArgs(buffer, start, end) {
writeFromFuture.then((ignore) {
Expect.fail('exception expected');
}).catchError((error) {
Expect.isTrue(error is FileIOException);
Expect.isTrue(error is FileException);
Expect.isTrue(error.toString().contains('Invalid arguments'));
file.close().then((ignore) {
port.close();
@ -117,14 +117,14 @@ void testWriteStringInvalidArgs(string, encoding) {
file.writeStringSync(string, encoding: encoding);
Expect.fail('exception expected');
} catch (e) {
Expect.isTrue(e is FileIOException);
Expect.isTrue(e is FileException);
}
var writeStringFuture = file.writeString(string, encoding: encoding);
writeStringFuture.then((ignore) {
Expect.fail('exception expected');
}).catchError((error) {
Expect.isTrue(error is FileIOException);
Expect.isTrue(error is FileException);
file.close().then((ignore) {
port.close();
});

View file

@ -713,7 +713,7 @@ class FileTest {
openedFile.closeSync();
try {
openedFile.readByteSync();
} on FileIOException catch (ex) {
} on FileException catch (ex) {
exceptionCaught = true;
} on Exception catch (ex) {
wrongExceptionCaught = true;
@ -723,7 +723,7 @@ class FileTest {
exceptionCaught = false;
try {
openedFile.writeByteSync(1);
} on FileIOException catch (ex) {
} on FileException catch (ex) {
exceptionCaught = true;
} on Exception catch (ex) {
wrongExceptionCaught = true;
@ -733,7 +733,7 @@ class FileTest {
exceptionCaught = false;
try {
openedFile.writeStringSync("Test");
} on FileIOException catch (ex) {
} on FileException catch (ex) {
exceptionCaught = true;
} on Exception catch (ex) {
wrongExceptionCaught = true;
@ -744,7 +744,7 @@ class FileTest {
try {
List<int> buffer = new List<int>(100);
openedFile.readIntoSync(buffer, 0, 10);
} on FileIOException catch (ex) {
} on FileException catch (ex) {
exceptionCaught = true;
} on Exception catch (ex) {
wrongExceptionCaught = true;
@ -755,7 +755,7 @@ class FileTest {
try {
List<int> buffer = new List<int>(100);
openedFile.writeFromSync(buffer, 0, 10);
} on FileIOException catch (ex) {
} on FileException catch (ex) {
exceptionCaught = true;
} on Exception catch (ex) {
wrongExceptionCaught = true;
@ -765,7 +765,7 @@ class FileTest {
exceptionCaught = false;
try {
openedFile.positionSync();
} on FileIOException catch (ex) {
} on FileException catch (ex) {
exceptionCaught = true;
} on Exception catch (ex) {
wrongExceptionCaught = true;
@ -775,7 +775,7 @@ class FileTest {
exceptionCaught = false;
try {
openedFile.lengthSync();
} on FileIOException catch (ex) {
} on FileException catch (ex) {
exceptionCaught = true;
} on Exception catch (ex) {
wrongExceptionCaught = true;
@ -785,7 +785,7 @@ class FileTest {
exceptionCaught = false;
try {
openedFile.flushSync();
} on FileIOException catch (ex) {
} on FileException catch (ex) {
exceptionCaught = true;
} on Exception catch (ex) {
wrongExceptionCaught = true;
@ -922,7 +922,7 @@ class FileTest {
f.openSync();
Expect.fail("Expected exception opening directory as file");
} catch (e) {
Expect.isTrue(e is FileIOException);
Expect.isTrue(e is FileException);
}
}
@ -1086,9 +1086,9 @@ class FileTest {
Expect.equals(1, message);
});
var f = new File('.');
Expect.throws(f.readAsBytesSync, (e) => e is FileIOException);
Expect.throws(f.readAsStringSync, (e) => e is FileIOException);
Expect.throws(f.readAsLinesSync, (e) => e is FileIOException);
Expect.throws(f.readAsBytesSync, (e) => e is FileException);
Expect.throws(f.readAsStringSync, (e) => e is FileException);
Expect.throws(f.readAsLinesSync, (e) => e is FileException);
var readAsBytesFuture = f.readAsBytes();
readAsBytesFuture.then((bytes) => Expect.fail("no bytes expected"))
.catchError((e) {

View file

@ -76,7 +76,7 @@ void testGetServerClose() {
Expect.fail("Request not expected");
})
.catchError((error) => port.close(),
test: (error) => error is HttpParserException);
test: (error) => error is HttpException);
});
}

View file

@ -6,6 +6,7 @@ import "package:expect/expect.dart";
import "dart:async";
import "dart:math";
part '../../../sdk/lib/io/common.dart';
part "../../../sdk/lib/io/io_sink.dart";
part "../../../sdk/lib/io/http.dart";
part "../../../sdk/lib/io/http_impl.dart";

View file

@ -6,6 +6,7 @@ import "package:expect/expect.dart";
import 'dart:async';
import 'dart:math';
part '../../../sdk/lib/io/common.dart';
part "../../../sdk/lib/io/io_sink.dart";
part "../../../sdk/lib/io/http.dart";
part "../../../sdk/lib/io/http_headers.dart";

View file

@ -8,6 +8,7 @@ import 'dart:math';
import 'dart:typed_data';
import 'dart:isolate';
part '../../../sdk/lib/io/common.dart';
part '../../../sdk/lib/io/io_sink.dart';
part '../../../sdk/lib/io/http.dart';
part '../../../sdk/lib/io/http_impl.dart';

View file

@ -391,7 +391,7 @@ void testAutoRedirectLimit() {
Expect.equals(5, error.redirects.length);
server.close();
client.close();
}, test: (e) => e is RedirectLimitExceededException);
}, test: (e) => e is RedirectException);
});
}
@ -406,7 +406,7 @@ void testRedirectLoop() {
Expect.equals(2, error.redirects.length);
server.close();
client.close();
}, test: (e) => e is RedirectLoopException);
}, test: (e) => e is RedirectException);
});
}

View file

@ -43,12 +43,12 @@ void testServerRequest(void handler(server, request),
client.close();
},
onError: (error) {
Expect.isTrue(error is HttpParserException);
Expect.isTrue(error is HttpException);
});
})
.catchError((error) {
client.close();
}, test: (e) => e is HttpParserException);
}, test: (e) => e is HttpException);
});
}

View file

@ -173,7 +173,7 @@ void test5(int totalConnections) {
return request.close();
})
.then((response) { })
.catchError((e) { }, test: (e) => e is HttpParserException);
.catchError((e) { }, test: (e) => e is HttpException);
}
bool clientClosed = false;
new Timer.periodic(new Duration(milliseconds: 100), (timer) {

View file

@ -33,7 +33,7 @@ void testInvalidBind() {
RawSecureServerSocket.bind("ko.faar.__hest__", 0, CERTIFICATE).then((_) {
Expect.fail("Failure expected");
}).catchError((error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
port.toSendPort().send(1);
});
@ -41,7 +41,7 @@ void testInvalidBind() {
RawSecureServerSocket.bind("8.8.8.8", 0, CERTIFICATE).then((_) {
Expect.fail("Failure expected");
}).catchError((error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
port.toSendPort().send(1);
});
@ -61,7 +61,7 @@ void testInvalidBind() {
})
.catchError((error) {
Expect.notEquals('windows', Platform.operatingSystem);
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
s.close();
port.toSendPort().send(1);
});
@ -91,13 +91,13 @@ void testSimpleConnectFail(String certificate, bool cancelOnError) {
Expect.fail("No client connection expected.");
})
.catchError((error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
});
server.listen((serverEnd) {
Expect.fail("No server connection expected.");
},
onError: (error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
clientEndFuture.then((_) {
if (!cancelOnError) server.close();
port.close();

View file

@ -35,7 +35,7 @@ void testInvalidBind() {
RawServerSocket.bind("ko.faar.__hest__", 0)
.then((_) { Expect.fail("Failure expected"); } )
.catchError((error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
port.toSendPort().send(1);
});
@ -43,7 +43,7 @@ void testInvalidBind() {
RawServerSocket.bind("8.8.8.8", 0)
.then((_) { Expect.fail("Failure expected"); } )
.catchError((error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
port.toSendPort().send(1);
});
@ -61,7 +61,7 @@ void testInvalidBind() {
})
.catchError((error) {
Expect.notEquals('windows', Platform.operatingSystem);
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
port.toSendPort().send(1);
});
});

View file

@ -14,7 +14,7 @@ void testGoogleUrl() {
.then((request) => request.close())
.then((response) => Expect.fail("Unexpected successful connection"))
.catchError((error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
keepAlive.close();
client.close();
});

View file

@ -14,7 +14,7 @@ void testGoogleUrl() {
.then((request) => request.close())
.then((response) => Expect.fail("Unexpected successful connection"))
.catchError((error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
keepAlive.close();
client.close();
});

View file

@ -33,7 +33,7 @@ void testInvalidBind() {
SecureServerSocket.bind("ko.faar.__hest__", 0, CERTIFICATE).then((_) {
Expect.fail("Failure expected");
}).catchError((error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
port.toSendPort().send(1);
});
@ -41,7 +41,7 @@ void testInvalidBind() {
SecureServerSocket.bind("8.8.8.8", 0, CERTIFICATE).then((_) {
Expect.fail("Failure expected");
}).catchError((error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
port.toSendPort().send(1);
});
@ -60,7 +60,7 @@ void testInvalidBind() {
port.toSendPort().send(1);
}).catchError((error) {
Expect.notEquals('windows', Platform.operatingSystem);
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
s.close();
port.toSendPort().send(1);
});
@ -90,13 +90,13 @@ void testSimpleConnectFail(String certificate, bool cancelOnError) {
Expect.fail("No client connection expected.");
})
.catchError((error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
});
server.listen((serverEnd) {
Expect.fail("No server connection expected.");
},
onError: (error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
clientEndFuture.then((_) {
if (!cancelOnError) server.close();
port.close();

View file

@ -20,7 +20,7 @@ class SocketExceptionTest {
server.close();
try {
server.close();
} on SocketIOException catch(ex) {
} on SocketException catch(ex) {
exceptionCaught = true;
} catch (ex) {
wrongExceptionCaught = true;
@ -31,7 +31,7 @@ class SocketExceptionTest {
// Test invalid host.
ServerSocket.bind("__INVALID_HOST__", 0)
.then((server) { })
.catchError((e) => e is SocketIOException);
.catchError((e) => e is SocketException);
});
}
@ -70,7 +70,7 @@ class SocketExceptionTest {
client.close();
try {
client.close();
} on SocketIOException catch(ex) {
} on SocketException catch(ex) {
exceptionCaught = true;
} catch (ex) {
wrongExceptionCaught = true;
@ -79,7 +79,7 @@ class SocketExceptionTest {
Expect.isFalse(wrongExceptionCaught);
try {
client.destroy();
} on SocketIOException catch(ex) {
} on SocketException catch(ex) {
exceptionCaught = true;
} catch (ex) {
print(ex);
@ -164,7 +164,7 @@ class SocketExceptionTest {
client.listen(
(data) => Expect.fail("Unexpected data"),
onError: (error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
errors++;
},
onDone: () {
@ -184,7 +184,7 @@ class SocketExceptionTest {
Expect.fail("Expected error");
},
onError: (error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
port.close();
});
});
@ -218,7 +218,7 @@ class SocketExceptionTest {
Socket.connect("hede.hule.hest", 1234)
.then((socket) => Expect.fail("Connection completed"))
.catchError((e) => port.close(), test: (e) => e is SocketIOException);
.catchError((e) => port.close(), test: (e) => e is SocketException);
}

View file

@ -20,7 +20,7 @@ class NotAList {
testSocketCreation(host, port) {
Socket.connect(host, port)
.then((socket) => Expect.fail("Shouldn't get connected"))
.catchError((e) => null, test: (e) => e is SocketIOException)
.catchError((e) => null, test: (e) => e is SocketException)
.catchError((e) => null, test: (e) => e is ArgumentError);
}

View file

@ -35,7 +35,7 @@ void testInvalidBind() {
ServerSocket.bind("ko.faar.__hest__", 0)
.then((_) { Expect.fail("Failure expected"); } )
.catchError((error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
port.toSendPort().send(1);
});
@ -43,7 +43,7 @@ void testInvalidBind() {
ServerSocket.bind("8.8.8.8", 0)
.then((_) { Expect.fail("Failure expected"); } )
.catchError((error) {
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
port.toSendPort().send(1);
});
@ -61,7 +61,7 @@ void testInvalidBind() {
})
.catchError((error) {
Expect.notEquals('windows', Platform.operatingSystem);
Expect.isTrue(error is SocketIOException);
Expect.isTrue(error is SocketException);
port.toSendPort().send(1);
});
});

View file

@ -6,6 +6,7 @@ import "package:expect/expect.dart";
import "dart:async";
import "dart:utf";
part '../../../sdk/lib/io/common.dart';
part '../../../sdk/lib/io/io_sink.dart';
part "../../../sdk/lib/io/http.dart";
part "../../../sdk/lib/io/http_impl.dart";

View file

@ -10,6 +10,7 @@ import "dart:collection";
import "dart:typed_data";
import "dart:isolate";
part '../../../sdk/lib/io/common.dart';
part "../../../sdk/lib/io/http.dart";
part "../../../sdk/lib/io/buffer_list.dart";
part "../../../sdk/lib/io/io_sink.dart";