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

Side by Side Diff: sdk/lib/io/common.dart

Issue 16123036: Clean up dart:io exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/utils.dart ('k') | sdk/lib/io/directory.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of dart.io; 5 part of dart.io;
6 6
7 // Constants used when working with native ports. 7 // Constants used when working with native ports.
8 // These must match the constants in runtime/bin/dartutils.h class CObject. 8 // These must match the constants in runtime/bin/dartutils.h class CObject.
9 const int _SUCCESS_RESPONSE = 0; 9 const int _SUCCESS_RESPONSE = 0;
10 const int _ILLEGAL_ARGUMENT_RESPONSE = 1; 10 const int _ILLEGAL_ARGUMENT_RESPONSE = 1;
(...skipping 13 matching lines...) Expand all
24 * Returns an Exception or an Error 24 * Returns an Exception or an Error
25 */ 25 */
26 _exceptionFromResponse(response, String message) { 26 _exceptionFromResponse(response, String message) {
27 assert(_isErrorResponse(response)); 27 assert(_isErrorResponse(response));
28 switch (response[_ERROR_RESPONSE_ERROR_TYPE]) { 28 switch (response[_ERROR_RESPONSE_ERROR_TYPE]) {
29 case _ILLEGAL_ARGUMENT_RESPONSE: 29 case _ILLEGAL_ARGUMENT_RESPONSE:
30 return new ArgumentError(); 30 return new ArgumentError();
31 case _OSERROR_RESPONSE: 31 case _OSERROR_RESPONSE:
32 var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE], 32 var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE],
33 response[_OSERROR_RESPONSE_ERROR_CODE]); 33 response[_OSERROR_RESPONSE_ERROR_CODE]);
34 return new FileIOException(message, err); 34 return new FileException(message, err);
35 case _FILE_CLOSED_RESPONSE: 35 case _FILE_CLOSED_RESPONSE:
36 return new FileIOException("File closed"); 36 return new FileException("File closed");
37 default: 37 default:
38 return new Exception("Unknown error"); 38 return new Exception("Unknown error");
39 } 39 }
40 } 40 }
41 41
42 /** 42 /**
43 * Base class for all IO related exceptions.
44 */
45 abstract class IOException implements Exception {
46 String toString() => "IOException";
47 }
48
49 /**
43 * An [OSError] object holds information about an error from the 50 * An [OSError] object holds information about an error from the
44 * operating system. 51 * operating system.
45 */ 52 */
46 class OSError implements Error { 53 class OSError {
47 /** Constant used to indicate that no OS error code is available. */ 54 /** Constant used to indicate that no OS error code is available. */
48 static const int noErrorCode = -1; 55 static const int noErrorCode = -1;
49 56
50 /** Creates an OSError object from a message and an errorCode. */ 57 /** Creates an OSError object from a message and an errorCode. */
51 const OSError([String this.message = "", int this.errorCode = noErrorCode]); 58 const OSError([String this.message = "", int this.errorCode = noErrorCode]);
52 59
53 /** Converts an OSError object to a string representation. */ 60 /** Converts an OSError object to a string representation. */
54 String toString() { 61 String toString() {
55 StringBuffer sb = new StringBuffer(); 62 StringBuffer sb = new StringBuffer();
56 sb.write("OS Error"); 63 sb.write("OS Error");
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 class _BufferUtils { 136 class _BufferUtils {
130 // Check if a List is a builtin VM List type. Returns true 137 // Check if a List is a builtin VM List type. Returns true
131 // if the List is a builtin VM List type and false if it is 138 // if the List is a builtin VM List type and false if it is
132 // a user defined List type. 139 // a user defined List type.
133 external static bool _isBuiltinList(List buffer); 140 external static bool _isBuiltinList(List buffer);
134 } 141 }
135 142
136 class _IOCrypto { 143 class _IOCrypto {
137 external static Uint8List getRandomBytes(int count); 144 external static Uint8List getRandomBytes(int count);
138 } 145 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/utils.dart ('k') | sdk/lib/io/directory.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698