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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/object.cc » ('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 * Interface implemented by all core library exceptions.
9 */ 9 */
10 interface Exception default ExceptionImplementation { 10 interface Exception default ExceptionImplementation {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 115
116 116
117 class WrongArgumentCountException implements Exception { 117 class WrongArgumentCountException implements Exception {
118 const WrongArgumentCountException(); 118 const WrongArgumentCountException();
119 String toString() => "WrongArgumentCountException"; 119 String toString() => "WrongArgumentCountException";
120 } 120 }
121 121
122 122
123 class NullPointerException implements Exception { 123 class NullPointerException implements Exception {
124 const NullPointerException(); 124 const NullPointerException([this.functionName,
125 String toString() => "NullPointerException"; 125 this.arguments = const[]]);
sra1 2012/04/11 20:43:12 NullPointerException is called from hand written J
126 String toString() {
127 StringBuffer sb = new StringBuffer();
128 for (var arg in arguments) {
129 if (!sb.isEmpty()) sb.add(", ");
130 sb.add(arg);
131 }
132 if (functionName == null) {
sra1 2012/04/11 20:43:12 Do this test first. No need to allocate a StringB
133 return exceptionName;
134 } else {
135 return "$exceptionName : method: '$functionName'\n"
136 "Receiver: null\n"
137 "Arguments: [$sb]";
138 }
139 }
140
141 String get exceptionName() => "NullPointerException";
142
143 final String functionName;
144 final List arguments;
126 } 145 }
127 146
128 147
129 class NoMoreElementsException implements Exception { 148 class NoMoreElementsException implements Exception {
130 const NoMoreElementsException(); 149 const NoMoreElementsException();
131 String toString() => "NoMoreElementsException"; 150 String toString() => "NoMoreElementsException";
132 } 151 }
133 152
134 153
135 class EmptyQueueException implements Exception { 154 class EmptyQueueException implements Exception {
(...skipping 20 matching lines...) Expand all
156 String toString() => "IllegalJSRegExpException: '$_pattern' '$_errmsg'"; 175 String toString() => "IllegalJSRegExpException: '$_pattern' '$_errmsg'";
157 final String _pattern; 176 final String _pattern;
158 final String _errmsg; 177 final String _errmsg;
159 } 178 }
160 179
161 180
162 class IntegerDivisionByZeroException implements Exception { 181 class IntegerDivisionByZeroException implements Exception {
163 const IntegerDivisionByZeroException(); 182 const IntegerDivisionByZeroException();
164 String toString() => "IntegerDivisionByZeroException"; 183 String toString() => "IntegerDivisionByZeroException";
165 } 184 }
OLDNEW
« 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