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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/core/errors.dart
diff --git a/sdk/lib/core/errors.dart b/sdk/lib/core/errors.dart
index c11ea2e1a97da25e0c73490a216d7ec025492dc6..8e7710889f9fce774d92a209b054f00e50033325 100644
--- a/sdk/lib/core/errors.dart
+++ b/sdk/lib/core/errors.dart
@@ -120,6 +120,24 @@ class NullThrownError extends Error {
}
/**
+ * Error thrown when attempting to dereference [:null:].
+ */
+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
+ /** Message describing the problem. */
+ final message;
+
+ /**
+ * The [message] optionally describes the circumstances
+ * under which [:null:] was dereferenced.
+ */
+ NullDereferenceError([this.message]);
+
+ String toString() {
+ 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
+ }
+}
+
+/**
* Error thrown when a function is passed an unacceptable argument.
*/
class ArgumentError extends Error {

Powered by Google App Engine
This is Rietveld 408576698