Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: runtime/bin/file_impl.dart

Issue 10095009: Make it an error to call close twice on a file using the async API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/standalone/src/io/FileErrorTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file_impl.dart
diff --git a/runtime/bin/file_impl.dart b/runtime/bin/file_impl.dart
index d9a336e7f4fd375de9bd2d05e4dc9e085115fe1b..66fb6bdfa11844e12399d43bff46378ca9cc4260 100644
--- a/runtime/bin/file_impl.dart
+++ b/runtime/bin/file_impl.dart
@@ -703,7 +703,12 @@ class _RandomAccessFile extends _FileBase implements RandomAccessFile {
_RandomAccessFile(int this._id, String this._name);
void close(void callback()) {
- if (_id == 0) return;
+ if (_id == 0) {
+ if (_onError != null) {
+ _onError(new FileIOException("Cannot close file: $_name"));
+ }
+ return;
+ }
_ensureFileService();
List request = new List(2);
request[0] = _FileUtils.kCloseRequest;
@@ -716,7 +721,7 @@ class _RandomAccessFile extends _FileBase implements RandomAccessFile {
_id = result;
callback();
} else if (_onError != null) {
- _onError("Cannot close file: $_name");
+ _onError(new FileIOException("Cannot close file: $_name"));
}
});
}
@@ -757,7 +762,7 @@ class _RandomAccessFile extends _FileBase implements RandomAccessFile {
_ensureFileService();
if (buffer is !List || offset is !int || bytes is !int) {
if (_onError != null) {
- _onError("Invalid arguments to readList");
+ _onError(new FileIOException("Invalid arguments to readList"));
}
return;
};
@@ -799,7 +804,7 @@ class _RandomAccessFile extends _FileBase implements RandomAccessFile {
_ensureFileService();
if (value is !int) {
if (_onError != null) {
- _onError("Invalid argument to writeByte");
+ _onError(new FileIOException("Invalid argument to writeByte"));
}
return;
}
@@ -832,7 +837,7 @@ class _RandomAccessFile extends _FileBase implements RandomAccessFile {
_ensureFileService();
if (buffer is !List || offset is !int || bytes is !int) {
if (_onError != null) {
- _onError("Invalid arguments to writeList");
+ _onError(new FileIOException("Invalid arguments to writeList"));
}
return;
}
« no previous file with comments | « no previous file | tests/standalone/src/io/FileErrorTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698