OLD | NEW |
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 Loading... |
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 Loading... |
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.isEmpty()) { |
| 375 sb.add(": $message"); |
| 376 if (osError != null) { |
| 377 sb.add(" ($osError)"); |
| 378 } |
| 379 } else if (osError != null) { |
| 380 sb.add(": osError"); |
| 381 } |
| 382 return sb.toString(); |
| 383 } |
371 final String message; | 384 final String message; |
| 385 final OSError osError; |
372 } | 386 } |
OLD | NEW |