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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 String toString() { | 43 String toString() { |
44 StringBuffer sb = new StringBuffer(); | 44 StringBuffer sb = new StringBuffer(); |
45 for (int i = 0; i < _arguments.length; i++) { | 45 for (int i = 0; i < _arguments.length; i++) { |
46 if (i > 0) { | 46 if (i > 0) { |
47 sb.add(", "); | 47 sb.add(", "); |
48 } | 48 } |
49 sb.add(_arguments[i]); | 49 sb.add(_arguments[i]); |
50 } | 50 } |
51 if (_existingArgumentNames === null) { | 51 if (_existingArgumentNames === null) { |
52 return "NoSuchMethodException : method not found: '$_functionName'\n" + | 52 return "NoSuchMethodException : method not found: '$_functionName'\n" |
53 "Receiver: $_receiver\n" + "Arguments: [$sb]"; | 53 "Receiver: $_receiver\n" |
| 54 "Arguments: [$sb]"; |
54 } else { | 55 } else { |
55 String actualParameters = sb.toString(); | 56 String actualParameters = sb.toString(); |
56 sb = new StringBuffer(); | 57 sb = new StringBuffer(); |
57 for (int i = 0; i < _existingArgumentNames.length; i++) { | 58 for (int i = 0; i < _existingArgumentNames.length; i++) { |
58 if (i > 0) { | 59 if (i > 0) { |
59 sb.add(", "); | 60 sb.add(", "); |
60 } | 61 } |
61 sb.add(_existingArgumentNames[i]); | 62 sb.add(_existingArgumentNames[i]); |
62 } | 63 } |
63 String formalParameters = sb.toString(); | 64 String formalParameters = sb.toString(); |
64 return "NoSuchMethodException: incorrect number of arguments passed to " + | 65 return "NoSuchMethodException: incorrect number of arguments passed to " |
65 "method named '$_functionName'\nReceiver: $_receiver\n" + | 66 "method named '$_functionName'\nReceiver: $_receiver\n" |
66 "Tried calling: $_functionName($actualParameters)\n" + | 67 "Tried calling: $_functionName($actualParameters)\n" |
67 "Found: $_functionName($formalParameters)"; | 68 "Found: $_functionName($formalParameters)"; |
68 } | 69 } |
69 } | 70 } |
70 | 71 |
71 final Object _receiver; | 72 final Object _receiver; |
72 final String _functionName; | 73 final String _functionName; |
73 final List _arguments; | 74 final List _arguments; |
74 final List _existingArgumentNames; | 75 final List _existingArgumentNames; |
75 } | 76 } |
76 | 77 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 String toString() => "IllegalJSRegExpException: '$_pattern' '$_errmsg'"; | 156 String toString() => "IllegalJSRegExpException: '$_pattern' '$_errmsg'"; |
156 final String _pattern; | 157 final String _pattern; |
157 final String _errmsg; | 158 final String _errmsg; |
158 } | 159 } |
159 | 160 |
160 | 161 |
161 class IntegerDivisionByZeroException implements Exception { | 162 class IntegerDivisionByZeroException implements Exception { |
162 const IntegerDivisionByZeroException(); | 163 const IntegerDivisionByZeroException(); |
163 String toString() => "IntegerDivisionByZeroException"; | 164 String toString() => "IntegerDivisionByZeroException"; |
164 } | 165 } |
OLD | NEW |