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 patch class Error { | 5 patch class Error { |
6 /* patch */ static String _objectToString(Object object) { | 6 /* patch */ static String _objectToString(Object object) { |
7 return Object._toString(object); | 7 return Object._toString(object); |
8 } | 8 } |
9 | 9 |
10 /* patch */ StackTrace get stackTrace => _stackTrace; | 10 /* patch */ StackTrace get stackTrace => _stackTrace; |
11 | 11 |
12 StackTrace _stackTrace; | 12 StackTrace _stackTrace; |
13 } | 13 } |
14 | 14 |
| 15 patch class AssertionError extends Error { |
| 16 AssertionError._create( |
| 17 this._failedAssertion, this._url, this._line, this._column); |
| 18 |
| 19 static _throwNew(int assertionStart, int assertionEnd) |
| 20 native "AssertionError_throwNew"; |
| 21 |
| 22 String toString() { |
| 23 return "'$_url': Failed assertion: line $_line pos $_column: " |
| 24 "'$_failedAssertion' is not true."; |
| 25 } |
| 26 final String _failedAssertion; |
| 27 final String _url; |
| 28 final int _line; |
| 29 final int _column; |
| 30 } |
| 31 |
| 32 patch class TypeError extends AssertionError { |
| 33 TypeError._create(String url, int line, int column, |
| 34 this._srcType, this._dstType, this._dstName, |
| 35 this._malformedError) |
| 36 : super._create("is assignable", url, line, column); |
| 37 |
| 38 static _throwNew(int location, |
| 39 Object src_value, |
| 40 String dst_type_name, |
| 41 String dst_name, |
| 42 String malformed_error) |
| 43 native "TypeError_throwNew"; |
| 44 |
| 45 String toString() { |
| 46 String str = (_malformedError != null) ? _malformedError : ""; |
| 47 if ((_dstName != null) && (_dstName.length > 0)) { |
| 48 str = "${str}type '$_srcType' is not a subtype of " |
| 49 "type '$_dstType' of '$_dstName'."; |
| 50 } else { |
| 51 str = "${str}malformed type used."; |
| 52 } |
| 53 return str; |
| 54 } |
| 55 |
| 56 final String _srcType; |
| 57 final String _dstType; |
| 58 final String _dstName; |
| 59 final String _malformedError; |
| 60 } |
| 61 |
| 62 patch class CastError extends Error { |
| 63 CastError._create(this._url, this._line, this._column, |
| 64 this._srcType, this._dstType, this._dstName, |
| 65 this._malformedError); |
| 66 |
| 67 // A CastError is allocated by TypeError._throwNew() when dst_name equals |
| 68 // Exceptions::kCastErrorDstName. |
| 69 |
| 70 String toString() { |
| 71 String str = (_malformedError != null) ? _malformedError : ""; |
| 72 str = "${str}type '$_srcType' is not a subtype of " |
| 73 "type '$_dstType' in type cast."; |
| 74 return str; |
| 75 } |
| 76 |
| 77 // Fields _url, _line, and _column are only used for debugging purposes. |
| 78 final String _url; |
| 79 final int _line; |
| 80 final int _column; |
| 81 final String _srcType; |
| 82 final String _dstType; |
| 83 final String _dstName; |
| 84 final String _malformedError; |
| 85 } |
| 86 |
| 87 patch class FallThroughError { |
| 88 FallThroughError._create(this._url, this._line); |
| 89 |
| 90 static _throwNew(int case_clause_pos) native "FallThroughError_throwNew"; |
| 91 |
| 92 /* patch */ String toString() { |
| 93 return "'$_url': Switch case fall-through at line $_line."; |
| 94 } |
| 95 |
| 96 // These new fields cannot be declared final, because a constructor exists |
| 97 // in the original version of this patched class. |
| 98 String _url; |
| 99 int _line; |
| 100 } |
| 101 |
| 102 class _InternalError { |
| 103 const _InternalError(this._msg); |
| 104 String toString() => "InternalError: '${_msg}'"; |
| 105 final String _msg; |
| 106 } |
| 107 |
| 108 |
| 109 patch class AbstractClassInstantiationError { |
| 110 AbstractClassInstantiationError._create( |
| 111 this._className, this._url, this._line); |
| 112 |
| 113 static _throwNew(int case_clause_pos, String className) |
| 114 native "AbstractClassInstantiationError_throwNew"; |
| 115 |
| 116 /* patch */ String toString() { |
| 117 return "Cannot instantiate abstract class $_className: " |
| 118 "_url '$_url' line $_line"; |
| 119 } |
| 120 |
| 121 // These new fields cannot be declared final, because a constructor exists |
| 122 // in the original version of this patched class. |
| 123 String _url; |
| 124 int _line; |
| 125 } |
| 126 |
15 patch class NoSuchMethodError { | 127 patch class NoSuchMethodError { |
16 // The compiler emits a call to _throwNew when it cannot resolve a static | 128 // The compiler emits a call to _throwNew when it cannot resolve a static |
17 // method at compile time. The receiver is actually the literal class of the | 129 // method at compile time. The receiver is actually the literal class of the |
18 // unresolved method. | 130 // unresolved method. |
19 static void _throwNew(Object receiver, | 131 static void _throwNew(Object receiver, |
20 String memberName, | 132 String memberName, |
21 int invocation_type, | 133 int invocation_type, |
22 List arguments, | 134 List arguments, |
23 List argumentNames, | 135 List argumentNames, |
24 List existingArgumentNames) { | 136 List existingArgumentNames) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 return msg_buf.toString(); | 289 return msg_buf.toString(); |
178 } | 290 } |
179 } | 291 } |
180 | 292 |
181 class _JavascriptIntegerOverflowError extends Error { | 293 class _JavascriptIntegerOverflowError extends Error { |
182 final Object _value; | 294 final Object _value; |
183 | 295 |
184 _JavascriptIntegerOverflowError(this._value); | 296 _JavascriptIntegerOverflowError(this._value); |
185 String toString() => "Javascript Integer Overflow: $_value"; | 297 String toString() => "Javascript Integer Overflow: $_value"; |
186 } | 298 } |
OLD | NEW |