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

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

Issue 2407603002: Give useful message for null derefs (Closed)
Patch Set: Give useful message for null derefs Created 4 years, 2 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
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 part of dart.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * Error objects thrown in the case of a program failure. 8 * Error objects thrown in the case of a program failure.
9 * 9 *
10 * An `Error` object represents a program failure that the programmer 10 * An `Error` object represents a program failure that the programmer
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 114
115 /** 115 /**
116 * Error thrown when attempting to throw [:null:]. 116 * Error thrown when attempting to throw [:null:].
117 */ 117 */
118 class NullThrownError extends Error { 118 class NullThrownError extends Error {
119 String toString() => "Throw of null."; 119 String toString() => "Throw of null.";
120 } 120 }
121 121
122 /** 122 /**
123 * Error thrown when attempting to dereference [:null:].
124 */
125 class NullDereferenceError extends Error implements NoSuchMethodError {
rmacnak 2016/10/10 21:29:39 DBC: Don't make this type public.
sra1 2016/10/10 21:50:40 This class also throws away information. You can't
sra1 2016/10/10 21:50:40 Yes, please remove from corelib. We can't reliably
126 /** Message describing the problem. */
127 final message;
128
129 /**
130 * The [message] optionally describes the circumstances
131 * under which [:null:] was dereferenced.
132 */
133 NullDereferenceError([this.message]);
134
135 String toString() {
136 return "Cannot dereference null.${ message != null ? ' $message' : ''}";
rmacnak 2016/10/10 21:29:39 DBC: There is no such operation as "dereferencing"
sra1 2016/10/10 21:50:40 Still use the 'no such method' terminology. This
137 }
138 }
139
140 /**
123 * Error thrown when a function is passed an unacceptable argument. 141 * Error thrown when a function is passed an unacceptable argument.
124 */ 142 */
125 class ArgumentError extends Error { 143 class ArgumentError extends Error {
126 /** Whether value was provided. */ 144 /** Whether value was provided. */
127 final bool _hasValue; 145 final bool _hasValue;
128 /** The invalid value. */ 146 /** The invalid value. */
129 final invalidValue; 147 final invalidValue;
130 /** Name of the invalid argument, if available. */ 148 /** Name of the invalid argument, if available. */
131 final String name; 149 final String name;
132 /** Message describing the problem. */ 150 /** Message describing the problem. */
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 * the first time it is read. If evaluating the initializer expression causes 582 * the first time it is read. If evaluating the initializer expression causes
565 * another read of the variable, this error is thrown. 583 * another read of the variable, this error is thrown.
566 */ 584 */
567 class CyclicInitializationError extends Error { 585 class CyclicInitializationError extends Error {
568 final String variableName; 586 final String variableName;
569 CyclicInitializationError([this.variableName]); 587 CyclicInitializationError([this.variableName]);
570 String toString() => variableName == null 588 String toString() => variableName == null
571 ? "Reading static variable during its initialization" 589 ? "Reading static variable during its initialization"
572 : "Reading static variable '$variableName' during its initialization"; 590 : "Reading static variable '$variableName' during its initialization";
573 } 591 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698