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

Side by Side Diff: utils/pub/io.dart

Issue 10916106: One more error code to check. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | « no previous file | no next file » | 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 /** 5 /**
6 * Helper functionality to make working with IO easier. 6 * Helper functionality to make working with IO easier.
7 */ 7 */
8 #library('io'); 8 #library('io');
9 9
10 #import('dart:io'); 10 #import('dart:io');
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 // #3657 is fixed. 319 // #3657 is fixed.
320 uri = _getUri(uri); 320 uri = _getUri(uri);
321 321
322 var completer = new Completer<String>(); 322 var completer = new Completer<String>();
323 var client = new HttpClient(); 323 var client = new HttpClient();
324 var connection = client.getUrl(uri); 324 var connection = client.getUrl(uri);
325 325
326 connection.onError = (e) { 326 connection.onError = (e) {
327 // Show a friendly error if the URL couldn't be resolved. 327 // Show a friendly error if the URL couldn't be resolved.
328 if (e is SocketIOException && 328 if (e is SocketIOException &&
329 (e.osError.errorCode == 8 || e.osError.errorCode == -2)) { 329 (e.osError.errorCode == 8 ||
330 e.osError.errorCode == -2 ||
331 e.osError.errorCode == -5)) {
330 e = 'Could not resolve URL "${uri.origin}".'; 332 e = 'Could not resolve URL "${uri.origin}".';
331 } 333 }
332 334
333 client.shutdown(); 335 client.shutdown();
334 completer.completeException(e); 336 completer.completeException(e);
335 }; 337 };
336 338
337 connection.onResponse = (response) { 339 connection.onResponse = (response) {
338 if (response.statusCode >= 400) { 340 if (response.statusCode >= 400) {
339 client.shutdown(); 341 client.shutdown();
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 return new Directory(entry); 551 return new Directory(entry);
550 } 552 }
551 553
552 /** 554 /**
553 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. 555 * Gets a [Uri] for [uri], which can either already be one, or be a [String].
554 */ 556 */
555 Uri _getUri(uri) { 557 Uri _getUri(uri) {
556 if (uri is Uri) return uri; 558 if (uri is Uri) return uri;
557 return new Uri.fromString(uri); 559 return new Uri.fromString(uri);
558 } 560 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698