Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 } |
| OLD | NEW |