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

Side by Side Diff: lib/core/errors.dart

Issue 11365059: Temporarily reintroduce IndexOutOfRangeError matcher in unittests. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed test expectations now that we are 100% backwards compatible. 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 | pkg/unittest/lib/src/core_matchers.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 class Error { 5 class Error {
6 const Error(); 6 const Error();
7 } 7 }
8 8
9 /** 9 /**
10 * Error thrown by the runtime system when an assert statement fails. 10 * Error thrown by the runtime system when an assert statement fails.
11 */ 11 */
12 class AssertionError implements Error { 12 class AssertionError implements Error {
13 } 13 }
14 14
15 /** 15 /**
16 * Error thrown by the runtime system when a type assertion fails. 16 * Error thrown by the runtime system when a type assertion fails.
17 */ 17 */
18 class TypeError implements AssertionError { 18 class TypeError implements AssertionError {
19 } 19 }
20 20
21 /** 21 /**
22 * Error thrown by the runtime system when a cast operation fails. 22 * Error thrown by the runtime system when a cast operation fails.
23 */ 23 */
24 class CastError implements Error { 24 class CastError implements Error {
25 } 25 }
26 26
27 /** 27 /**
28 * Error thrown when a function is passed an unacceptable argument. 28 * Error thrown when a function is passed an unacceptable argument.
29 */ 29 */
30 class ArgumentError implements Error { 30 class ArgumentError implements Error {
31 final message; 31 final message;
32 32
33 /** The [message] describes the erroneous argument. */ 33 /** The [message] describes the erroneous argument. */
34 const ArgumentError([this.message = ""]); 34 const ArgumentError([this.message]);
35 35
36 String toString() { 36 String toString() {
37 if (message != null) { 37 if (message != null) {
38 return "Illegal argument(s): $message"; 38 return "Illegal argument(s): $message";
39 } 39 }
40 return "Illegal argument(s)"; 40 return "Illegal argument(s)";
41 } 41 }
42 } 42 }
43 43
44 /** 44 /**
45 * Exception thrown because of an index outside of the valid range. 45 * Exception thrown because of an index outside of the valid range.
46 * 46 *
47 * Temporarily extends [Exception] for backwards compatiblity. 47 * Temporarily implements [IndexOutOfRangeException] for backwards compatiblity.
48 */ 48 */
49 class RangeError extends ArgumentError implements Exception { 49 class RangeError extends ArgumentError implements IndexOutOfRangeException {
50 // TODO(lrn): This constructor should be called only with string values. 50 // TODO(lrn): This constructor should be called only with string values.
51 // It currently isn't in all cases. 51 // It currently isn't in all cases.
52 /** Create a new [RangeError] with the given [message]. */ 52 /**
53 RangeError(var message) : super("$message"); 53 * Create a new [RangeError] with the given [message].
54 *
55 * Temporarily made const for backwards compatibilty.
56 */
57 const RangeError(var message) : super(message);
54 58
55 /** Create a new [RangeError] with a message for the given [value]. */ 59 /** Create a new [RangeError] with a message for the given [value]. */
56 RangeError.value(num value) : super("value $value"); 60 RangeError.value(num value) : super("value $value");
57 61
58 String toString() => "RangeError: $message"; 62 String toString() => "RangeError: $message";
59 } 63 }
60 64
61 /** 65 /**
62 * Temporary backwards compatibilty class. 66 * Temporary backwards compatibilty class.
63 * 67 *
64 * This class allows code throwing the old [IndexOutOfRangeException] to 68 * This class allows code throwing the old [IndexOutOfRangeException] to
65 * work until they change to the new [RangeError] name. 69 * work until they change to the new [RangeError] name.
66 * Code **catching** IndexOutOfRangeException will fail to catch 70 * Constructor of [RangeError] is const only to support this interface.
67 * the [RangeError] objects that are now thrown.
68 */ 71 */
69 class IndexOutOfRangeException extends ArgumentError { 72 interface IndexOutOfRangeException extends Exception default RangeError {
70 IndexOutOfRangeException(var message) : super(message); 73 const IndexOutOfRangeException(var message);
71 } 74 }
72 75
73 76
74 /** 77 /**
75 * Temporary backwards compatibility class. 78 * Temporary backwards compatibility class.
76 * 79 *
77 * Removed when users have had time to change to using [ArgumentError]. 80 * Removed when users have had time to change to using [ArgumentError].
78 */ 81 */
79 class IllegalArgumentException extends ArgumentError { 82 class IllegalArgumentException extends ArgumentError {
80 const IllegalArgumentException([argument = ""]) : super(argument); 83 const IllegalArgumentException([argument = ""]) : super(argument);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 224
222 class OutOfMemoryError implements Error { 225 class OutOfMemoryError implements Error {
223 const OutOfMemoryError(); 226 const OutOfMemoryError();
224 String toString() => "Out of Memory"; 227 String toString() => "Out of Memory";
225 } 228 }
226 229
227 class StackOverflowError implements Error { 230 class StackOverflowError implements Error {
228 const StackOverflowError(); 231 const StackOverflowError();
229 String toString() => "Stack Overflow"; 232 String toString() => "Stack Overflow";
230 } 233 }
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/lib/src/core_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698