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

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

Issue 14253005: Migrate pub away from throwing strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 years, 8 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 | « utils/pub/source_registry.dart ('k') | utils/tests/pub/command_line_config.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 /// Generic utility functions. Stuff that should possibly be in core. 5 /// Generic utility functions. Stuff that should possibly be in core.
6 library utils; 6 library utils;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:crypto'; 9 import 'dart:crypto';
10 import 'dart:io';
10 import 'dart:isolate'; 11 import 'dart:isolate';
11 import 'dart:uri'; 12 import 'dart:uri';
12 13
13 /// A pair of values. 14 /// A pair of values.
14 class Pair<E, F> { 15 class Pair<E, F> {
15 E first; 16 E first;
16 F last; 17 F last;
17 18
18 Pair(this.first, this.last); 19 Pair(this.first, this.last);
19 20
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 .then((resolved) => new Pair(key, resolved))); 352 .then((resolved) => new Pair(key, resolved)));
352 }); 353 });
353 return Future.wait(pairs).then((resolvedPairs) { 354 return Future.wait(pairs).then((resolvedPairs) {
354 var map = {}; 355 var map = {};
355 for (var pair in resolvedPairs) { 356 for (var pair in resolvedPairs) {
356 map[pair.first] = pair.last; 357 map[pair.first] = pair.last;
357 } 358 }
358 return map; 359 return map;
359 }); 360 });
360 } 361 }
362
363 /// An exception class for exceptions that are intended to be seen by the user.
364 /// These exceptions won't have any debugging information printed when they're
365 /// thrown.
366 class UserFacingException implements Exception {
367 final String message;
368
369 UserFacingException(this.message);
370 }
371
372 /// Throw a [UserFacingException] with [message].
373 void fail(String message) {
374 throw new UserFacingException(message);
375 }
376
377 /// Returns whether [error] is a user-facing error object. This includes both
378 /// [UserFacingException] and any dart:io errors.
379 bool isUserFacingException(error) {
380 return error is UserFacingException ||
381 // TODO(nweiz): clean up this branch when issue 9955 is fixed.
382 error is DirectoryIOException ||
383 error is FileIOException ||
384 error is HttpException ||
385 error is HttpParserException ||
386 error is LinkIOException ||
387 error is MimeParserException ||
388 error is OSError ||
389 error is ProcessException ||
390 error is SocketIOException ||
391 error is WebSocketException;
392 }
OLDNEW
« no previous file with comments | « utils/pub/source_registry.dart ('k') | utils/tests/pub/command_line_config.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698