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

Unified Diff: runtime/bin/file_impl.dart

Issue 10206023: Make sure that errors are thrown when there is no error handler (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 | runtime/bin/stream_util.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 173dd557791772227e1660e2bffb7dac3c8f4970..fda6435dc052c8380531dde7da933dc3b3388ca4 100644
--- a/runtime/bin/file_impl.dart
+++ b/runtime/bin/file_impl.dart
@@ -7,11 +7,7 @@ class _FileInputStream extends _BaseDataInputStream implements InputStream {
_file = new File(name);
_data = [];
_position = 0;
- _file.onError = (e) {
- if (_clientErrorHandler != null) {
- _clientErrorHandler(e);
- }
- };
+ _file.onError = _reportError;
_file.open(FileMode.READ, (openedFile) {
_readDataFromFile(openedFile);
});
@@ -26,19 +22,14 @@ class _FileInputStream extends _BaseDataInputStream implements InputStream {
}
void _readDataFromFile(RandomAccessFile openedFile) {
- openedFile.onError = (e) {
- if (_clientErrorHandler != null) {
- _clientErrorHandler(e);
- }
- };
+ openedFile.onError = _reportError;
openedFile.length((length) {
var contents = new ByteArray(length);
if (length != 0) {
openedFile.readList(contents, 0, length, (read) {
if (read != length) {
- if (_clientErrorHandler != null) {
- _clientErrorHandler();
- }
+ _reportError(new FileIOException(
+ 'Failed reading file contents in FileInputStream'));
} else {
_data = contents;
}
@@ -100,7 +91,7 @@ class _FileOutputStream extends _BaseOutputStream implements OutputStream {
_setupFileHandlers();
_processPendingOperations();
});
- f.onError = (e) => _reportError(e);
+ f.onError = _reportError;
}
_FileOutputStream.fromStdio(int fd) {
@@ -111,7 +102,7 @@ class _FileOutputStream extends _BaseOutputStream implements OutputStream {
void _setupFileHandlers() {
- _file.onError = (e) => _reportError(e);
+ _file.onError = _reportError;
_file.onNoPendingWrites = () {
if (!_streamMarkedClosed && _onNoPendingWrites != null) {
_onNoPendingWrites();
@@ -298,7 +289,7 @@ class _FileUtils {
};
var result = open(name, mode);
if (result is OSError) {
- throw new FileIOException("Cannot open file", result);
+ throw new FileIOException("Cannot open file $name", result);
}
return result;
}
@@ -425,7 +416,7 @@ class _File extends _FileBase implements File {
request[1] = _name;
_fileService.call(request).then((response) {
if (_isErrorResponse(response)) {
- _handleErrorResponse(response, "Cannot open file");
+ _handleErrorResponse(response, "Cannot open file $_name");
} else {
callback(response);
}
@@ -508,7 +499,7 @@ class _File extends _FileBase implements File {
request[2] = mode._mode; // Direct int value for serialization.
_fileService.call(request).then((response) {
if (_isErrorResponse(response)) {
- _handleErrorResponse(response, "Cannot open file");
+ _handleErrorResponse(response, "Cannot open file $_name");
} else {
callback(new _RandomAccessFile(response, _name));
}
« no previous file with comments | « no previous file | runtime/bin/stream_util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698