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

Unified Diff: runtime/bin/file_impl.dart

Issue 9630012: Error reporting on File in dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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
Index: runtime/bin/file_impl.dart
diff --git a/runtime/bin/file_impl.dart b/runtime/bin/file_impl.dart
index 8ab5bbbf29afdd5e61c5212dd2c4bdf2f46cc393..f4dfa7697dfcbd41f962471d6c97072ab4553b45 100644
--- a/runtime/bin/file_impl.dart
+++ b/runtime/bin/file_impl.dart
@@ -251,7 +251,7 @@ class _FileUtils {
}
static bool exists(String name) native "File_Exists";
- static int open(String name, int mode) native "File_Open";
+ static int open(String name, int mode, OSError error) native "File_Open";
static bool create(String name) native "File_Create";
static bool delete(String name) native "File_Delete";
static String fullPath(String name) native "File_FullPath";
@@ -281,7 +281,12 @@ class _FileUtils {
static int checkedOpen(String name, int mode) {
if (name is !String || mode is !int) return 0;
- return open(name, mode);
+ var osError = new OSError();
+ int id = open(name, mode, osError);
+ if (id == 0) {
+ throw new FileIOException("Cannot open file", osError);
+ }
+ return id;
}
static bool checkedCreate(String name) {
@@ -440,11 +445,14 @@ class _File implements File {
request[0] = _FileUtils.kOpenRequest;
request[1] = _name;
request[2] = mode._mode; // Direct int value for serialization.
- _fileService.call(request).receive((id, replyTo) {
- if (id != 0) {
+ _fileService.call(request).receive((result, replyTo) {
+ if (result is Array) {
+ if (_onError != null) {
+ //_onError("Cannot open file: ${result[0]} ${result[1]}");
Mads Ager (google) 2012/03/08 15:04:27 Code in comments and long line.
Søren Gjesse 2012/03/08 22:50:53 Done.
+ _onError(new FileIOException("Cannot open file", new OSError(result[1], result[0])));
+ }
+ } else {
callback(new _RandomAccessFile(id, _name));
- } else if (_onError != null) {
- _onError("Cannot open file: $_name");
}
});
}

Powered by Google App Engine
This is Rietveld 408576698