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

Unified Diff: sdk/lib/core/exceptions.dart

Issue 11369243: Make Exception a class, not an interface, and remove the const constructor. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated. Moved safeToString to Error. Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/core/errors.dart ('k') | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/exceptions.dart
diff --git a/sdk/lib/core/exceptions.dart b/sdk/lib/core/exceptions.dart
index 61f3f89def79b09ac9016b15ec8100704051971a..70278836096d55de80b6ce1f2bbcf9fb0892ca9b 100644
--- a/sdk/lib/core/exceptions.dart
+++ b/sdk/lib/core/exceptions.dart
@@ -5,19 +5,31 @@
// Exceptions are thrown either by the VM or from Dart code.
/**
- * Interface implemented by all core library exceptions.
- * Defaults to an implementation that only carries a simple message.
+ * A marker interface implemented by all core library exceptions.
+ *
+ * An [Exception] is intended to convey information to the user about a failure,
+ * so that the error can be addressed programmatically. It is intended to be
+ * caught, and it should contain useful data fields.
+ *
+ * Creating instances of [Exception] directly with [:new Exception("message"):]
+ * is discouraged, and only included as a temporary measure during development,
+ * until the actual exceptions used by a library are done.
*/
abstract class Exception {
- const factory Exception([var message]) = _ExceptionImplementation;
+ factory Exception([var message]) => new _ExceptionImplementation(message);
}
/** Default implementation of [Exception] which carries a message. */
class _ExceptionImplementation implements Exception {
final message;
- const _ExceptionImplementation([this.message]);
- String toString() => (message == null) ? "Exception" : "Exception: $message";
+
+ _ExceptionImplementation([this.message]);
+
+ String toString() {
+ if (message == null) return "Exception";
+ return "Exception: $message";
+ }
}
« no previous file with comments | « sdk/lib/core/errors.dart ('k') | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698