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

Side by Side Diff: runtime/bin/file.dart

Issue 9630012: Error reporting on File in dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased and implemented on all platforms 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 5
6 /** 6 /**
7 * FileMode describes the modes in which a file can be opened. 7 * FileMode describes the modes in which a file can be opened.
8 */ 8 */
9 class FileMode { 9 class FileMode {
10 static final READ = const FileMode._internal(0); 10 static final READ = const FileMode._internal(0);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 /** 198 /**
199 * Get the name of the file. 199 * Get the name of the file.
200 */ 200 */
201 String get name(); 201 String get name();
202 202
203 /** 203 /**
204 * Sets the handler that gets called when errors occur during 204 * Sets the handler that gets called when errors occur during
205 * operations on this file. 205 * operations on this file.
206 */ 206 */
207 void set onError(void handler(String error)); 207 void set onError(void handler(Exception e));
208 } 208 }
209 209
210 210
211 /** 211 /**
212 * [RandomAccessFile] provides random access to the data in a 212 * [RandomAccessFile] provides random access to the data in a
213 * file. [RandomAccessFile] objects are obtained by calling the 213 * file. [RandomAccessFile] objects are obtained by calling the
214 * [:open:] method on a [File] object. 214 * [:open:] method on a [File] object.
215 */ 215 */
216 interface RandomAccessFile { 216 interface RandomAccessFile {
217 /** 217 /**
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 359
360 /** 360 /**
361 * Sets the handler that gets called when errors occur when 361 * Sets the handler that gets called when errors occur when
362 * operating on this file. 362 * operating on this file.
363 */ 363 */
364 void set onError(void handler(String error)); 364 void set onError(void handler(String error));
365 } 365 }
366 366
367 367
368 class FileIOException implements Exception { 368 class FileIOException implements Exception {
369 const FileIOException([String this.message = ""]); 369 const FileIOException([String this.message = "",
370 String toString() => "FileIOException: $message"; 370 OSError this.osError = null]);
371 String toString() {
372 StringBuffer sb = new StringBuffer();
373 sb.add("FileIOException");
374 if (message != null) {
Mads Ager (google) 2012/03/13 10:56:17 !message.isEmpty()?
Søren Gjesse 2012/03/13 12:39:49 Done.
375 sb.add(": $message");
376 if (osError != null) {
377 sb.add(" (${osError.toString()})");
Mads Ager (google) 2012/03/13 10:56:17 You shouldn't have to explictly call toString here
Søren Gjesse 2012/03/13 12:39:49 Done.
378 }
379 } else if (osError != null) {
380 sb.add(": ${osError.toString()}");
Mads Ager (google) 2012/03/13 10:56:17 Ditto.
Søren Gjesse 2012/03/13 12:39:49 Done.
381 }
382 return sb.toString();
383 }
371 final String message; 384 final String message;
385 final OSError osError;
372 } 386 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698