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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/html/dart2js/html_dart2js.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 // Exceptions are thrown either by the VM or from Dart code. 5 // Exceptions are thrown either by the VM or from Dart code.
6 6
7 /** 7 /**
8 * Interface implemented by all core library exceptions. 8 * Marker interface implemented by all core library exceptions.
9 * Defaults to an implementation that only carries a simple message. 9 * Defaults to an implementation that only carries a simple message.
10 */ 10 */
11 interface Exception default _ExceptionImplementation { 11 abstract class Exception {
12 // TODO(lrn): This should be an abstract class, but we don't yet support 12 factory Exception([var message]) => new _ExceptionImplementation(message);
13 // redirecting factory constructors.
14 const Exception([var message]);
15 } 13 }
16 14
17 15
18 /** Default implementation of [Exception] which carries a message. */ 16 /** Default implementation of [Exception] which carries a message. */
19 class _ExceptionImplementation implements Exception { 17 class _ExceptionImplementation implements Exception {
20 final message; 18 final message;
21 const _ExceptionImplementation([this.message]); 19 const _ExceptionImplementation([this.message]);
22 String toString() => (message == null) ? "Exception" : "Exception: $message"; 20 String toString() => (message == null) ? "Exception" : "Exception: $message";
floitsch 2012/11/14 15:43:22 safeToString?
Bob Nystrom 2012/11/14 18:02:39 Nit, but I would prefer it if "Exception: " were n
Lasse Reichstein Nielsen 2012/11/16 08:22:49 It should be a String, but better safe than sorry.
Lasse Reichstein Nielsen 2012/11/19 13:18:53 Seems some tests expect the exact output that we c
23 } 21 }
24 22
25 23
26 /** 24 /**
27 * Exception thrown when a string or some other data does not have an expected 25 * Exception thrown when a string or some other data does not have an expected
28 * format and cannot be parsed or processed. 26 * format and cannot be parsed or processed.
29 */ 27 */
30 class FormatException implements Exception { 28 class FormatException implements Exception {
31 /** 29 /**
32 * A message describing the format error. 30 * A message describing the format error.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 73 }
76 74
77 /** 75 /**
78 * Exception thrown when a runtime error occurs. 76 * Exception thrown when a runtime error occurs.
79 */ 77 */
80 class RuntimeError implements Exception { 78 class RuntimeError implements Exception {
81 final message; 79 final message;
82 RuntimeError(this.message); 80 RuntimeError(this.message);
83 String toString() => "RuntimeError: $message"; 81 String toString() => "RuntimeError: $message";
84 } 82 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698