OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /** | 7 /** |
8 * [Link] objects are references to filesystem links. | 8 * [Link] objects are references to filesystem links. |
9 * | 9 * |
10 */ | 10 */ |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 200 |
201 bool _isErrorResponse(response) { | 201 bool _isErrorResponse(response) { |
202 return response is List && response[0] != _SUCCESS_RESPONSE; | 202 return response is List && response[0] != _SUCCESS_RESPONSE; |
203 } | 203 } |
204 | 204 |
205 void _ensureFileService() { | 205 void _ensureFileService() { |
206 if (_fileService == null) { | 206 if (_fileService == null) { |
207 _fileService = _FileUtils._newServicePort(); | 207 _fileService = _FileUtils._newServicePort(); |
208 } | 208 } |
209 } | 209 } |
| 210 |
| 211 _exceptionFromResponse(response, String message) { |
| 212 assert(_isErrorResponse(response)); |
| 213 switch (response[_ERROR_RESPONSE_ERROR_TYPE]) { |
| 214 case _ILLEGAL_ARGUMENT_RESPONSE: |
| 215 return new ArgumentError(); |
| 216 case _OSERROR_RESPONSE: |
| 217 var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE], |
| 218 response[_OSERROR_RESPONSE_ERROR_CODE]); |
| 219 return new FileIOException(message, err); |
| 220 case _FILE_CLOSED_RESPONSE: |
| 221 return new FileIOException("File closed"); |
| 222 default: |
| 223 return new Exception("Unknown error"); |
| 224 } |
| 225 } |
210 } | 226 } |
211 | 227 |
212 | 228 |
213 class LinkIOException implements Exception { | 229 class LinkIOException implements Exception { |
214 const LinkIOException([String this.message = "", | 230 const LinkIOException([String this.message = "", |
215 String this.path = "", | 231 String this.path = "", |
216 OSError this.osError = null]); | 232 OSError this.osError = null]); |
217 String toString() { | 233 String toString() { |
218 StringBuffer sb = new StringBuffer(); | 234 StringBuffer sb = new StringBuffer(); |
219 sb.write("LinkIOException"); | 235 sb.write("LinkIOException"); |
(...skipping 10 matching lines...) Expand all Loading... |
230 if (path != null) { | 246 if (path != null) { |
231 sb.write(", path = $path"); | 247 sb.write(", path = $path"); |
232 } | 248 } |
233 } | 249 } |
234 return sb.toString(); | 250 return sb.toString(); |
235 } | 251 } |
236 final String message; | 252 final String message; |
237 final String path; | 253 final String path; |
238 final OSError osError; | 254 final OSError osError; |
239 } | 255 } |
OLD | NEW |