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 /// Generic utility functions. Stuff that should possibly be in core. | 5 /// Generic utility functions. Stuff that should possibly be in core. |
6 library pub.utils; | 6 library pub.utils; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import "dart:convert"; | 9 import "dart:convert"; |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
812 } | 812 } |
813 | 813 |
814 /// Throw a [ApplicationException] with [message]. | 814 /// Throw a [ApplicationException] with [message]. |
815 void fail(String message, [innerError, StackTrace innerTrace]) { | 815 void fail(String message, [innerError, StackTrace innerTrace]) { |
816 if (innerError != null) { | 816 if (innerError != null) { |
817 throw new WrappedException(message, innerError, innerTrace); | 817 throw new WrappedException(message, innerError, innerTrace); |
818 } else { | 818 } else { |
819 throw new ApplicationException(message); | 819 throw new ApplicationException(message); |
820 } | 820 } |
821 } | 821 } |
822 | |
823 /// Throw a [DataException] with [message] to indicate that the command has | |
824 /// failed because of invalid input data. | |
825 /// | |
826 /// This will report the error and cause pub to exit with [exit_codes.DATA]. | |
827 void dataError(String message) { | |
828 throw new DataException(message); | |
nweiz
2014/06/26 22:43:26
Is this really worth having a custom function for?
Bob Nystrom
2014/06/27 00:30:23
I like having it mainly because it mirrors usageEr
nweiz
2014/06/30 19:42:28
I don't think this parallel will be clear to peopl
Bob Nystrom
2014/06/30 20:36:01
In a later patch, usageError() ends up getting mov
| |
829 } | |
OLD | NEW |