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

Unified Diff: corelib/src/exceptions.dart

Issue 10034026: Add optional arguments to NullPointerException so that it can report more information (make it simi… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « no previous file | runtime/lib/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: corelib/src/exceptions.dart
===================================================================
--- corelib/src/exceptions.dart (revision 6423)
+++ corelib/src/exceptions.dart (working copy)
@@ -121,8 +121,27 @@
class NullPointerException implements Exception {
- const NullPointerException();
- String toString() => "NullPointerException";
+ const NullPointerException([this.functionName,
+ this.arguments = const[]]);
sra1 2012/04/11 20:43:12 NullPointerException is called from hand written J
+ String toString() {
+ StringBuffer sb = new StringBuffer();
+ for (var arg in arguments) {
+ if (!sb.isEmpty()) sb.add(", ");
+ sb.add(arg);
+ }
+ if (functionName == null) {
sra1 2012/04/11 20:43:12 Do this test first. No need to allocate a StringB
+ return exceptionName;
+ } else {
+ return "$exceptionName : method: '$functionName'\n"
+ "Receiver: null\n"
+ "Arguments: [$sb]";
+ }
+ }
+
+ String get exceptionName() => "NullPointerException";
+
+ final String functionName;
+ final List arguments;
}
« no previous file with comments | « no previous file | runtime/lib/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698