| 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 // Errors are created and thrown by DartVM only. | 4 // Errors are created and thrown by DartVM only. |
| 5 // Changes here should also be reflected in corelib/error.dart as well | 5 // Changes here should also be reflected in corelib/error.dart as well |
| 6 | 6 |
| 7 class AssertionErrorImplementation extends AssertionError { | 7 class _AssertionErrorImplementation extends AssertionError { |
| 8 factory AssertionErrorImplementation._uninstantiable() { | 8 _AssertionErrorImplementation( |
| 9 throw new UnsupportedError( | 9 this.failedAssertion, this.url, this.line, this.column); |
| 10 "AssertionError can only be allocated by the VM"); | 10 |
| 11 } | |
| 12 static _throwNew(int assertionStart, int assertionEnd) | 11 static _throwNew(int assertionStart, int assertionEnd) |
| 13 native "AssertionError_throwNew"; | 12 native "AssertionError_throwNew"; |
| 13 |
| 14 String toString() { | 14 String toString() { |
| 15 return "'$url': Failed assertion: line $line pos $column: " | 15 return "'$url': Failed assertion: line $line pos $column: " |
| 16 "'$failedAssertion' is not true."; | 16 "'$failedAssertion' is not true."; |
| 17 } | 17 } |
| 18 final String failedAssertion; | 18 final String failedAssertion; |
| 19 final String url; | 19 final String url; |
| 20 final int line; | 20 final int line; |
| 21 final int column; | 21 final int column; |
| 22 } | 22 } |
| 23 | 23 |
| 24 class TypeErrorImplementation | 24 class _TypeErrorImplementation |
| 25 extends AssertionErrorImplementation | 25 extends _AssertionErrorImplementation |
| 26 implements TypeError { | 26 implements TypeError { |
| 27 factory TypeErrorImplementation._uninstantiable() { | 27 |
| 28 throw new UnsupportedError( | 28 _TypeErrorImplementation( |
| 29 "TypeError can only be allocated by the VM"); | 29 String failedAssertion, String url, int line, int column, |
| 30 } | 30 this.srcType, this.dstType, this.dstName, this._malformedError) |
| 31 : super(failedAssertion, url, line, column); |
| 32 |
| 31 static _throwNew(int location, | 33 static _throwNew(int location, |
| 32 Object src_value, | 34 Object src_value, |
| 33 String dst_type_name, | 35 String dst_type_name, |
| 34 String dst_name, | 36 String dst_name, |
| 35 String malformed_error) | 37 String malformed_error) |
| 36 native "TypeError_throwNew"; | 38 native "TypeError_throwNew"; |
| 39 |
| 37 String toString() { | 40 String toString() { |
| 38 String str = (malformedError != null) ? malformedError : ""; | 41 String str = (_malformedError != null) ? _malformedError : ""; |
| 39 if ((dstName != null) && (dstName.length > 0)) { | 42 if ((dstName != null) && (dstName.length > 0)) { |
| 40 str = "${str}type '$srcType' is not a subtype of " | 43 str = "${str}type '$srcType' is not a subtype of " |
| 41 "type '$dstType' of '$dstName'."; | 44 "type '$dstType' of '$dstName'."; |
| 42 } else { | 45 } else { |
| 43 str = "${str}malformed type used."; | 46 str = "${str}malformed type used."; |
| 44 } | 47 } |
| 45 return str; | 48 return str; |
| 46 } | 49 } |
| 50 |
| 47 final String srcType; | 51 final String srcType; |
| 48 final String dstType; | 52 final String dstType; |
| 49 final String dstName; | 53 final String dstName; |
| 50 final String malformedError; | 54 final String _malformedError; |
| 51 } | 55 } |
| 52 | 56 |
| 53 class CastErrorImplementation | 57 class _CastErrorImplementation |
| 54 extends TypeErrorImplementation | 58 extends _TypeErrorImplementation |
| 55 implements CastError { | 59 implements CastError { |
| 56 factory CastErrorImplementation._uninstantiable() { | 60 |
| 57 throw new UnsupportedError( | 61 _CastErrorImplementation( |
| 58 "CastError can only be allocated by the VM"); | 62 String failedAssertion, String url, int line, int column, |
| 59 } | 63 String srcType, String dstType, String dstName, String malformedError) |
| 64 : super(failedAssertion, url, line, column, |
| 65 srcType, dstType, dstName, malformedError); |
| 66 |
| 60 // A CastError is allocated by TypeError._throwNew() when dst_name equals | 67 // A CastError is allocated by TypeError._throwNew() when dst_name equals |
| 61 // Exceptions::kCastErrorDstName. | 68 // Exceptions::kCastErrorDstName. |
| 62 String toString() { | 69 String toString() { |
| 63 String str = (malformedError != null) ? malformedError : ""; | 70 String str = (_malformedError != null) ? _malformedError : ""; |
| 64 if ((dstName != null) && (dstName.length > 0)) { | 71 if ((dstName != null) && (dstName.length > 0)) { |
| 65 str = "${str}type '$srcType' is not a subtype of " | 72 str = "${str}type '$srcType' is not a subtype of " |
| 66 "type '$dstType' in type cast."; | 73 "type '$dstType' in type cast."; |
| 67 } else { | 74 } else { |
| 68 str = "${str}malformed type used in type cast."; | 75 str = "${str}malformed type used in type cast."; |
| 69 } | 76 } |
| 70 return str; | 77 return str; |
| 71 } | 78 } |
| 72 } | 79 } |
| 73 | 80 |
| 74 class FallThroughErrorImplementation extends FallThroughError { | 81 class _FallThroughErrorImplementation extends FallThroughError { |
| 75 factory FallThroughErrorImplementation._uninstantiable() { | 82 |
| 76 throw new UnsupportedError( | 83 _FallThroughErrorImplementation(this._url, this._line); |
| 77 "FallThroughError can only be allocated by the VM"); | 84 |
| 85 static _throwNew(int case_clause_pos) native "FallThroughError_throwNew"; |
| 86 |
| 87 String toString() { |
| 88 return "'$_url': Switch case fall-through at line $_line."; |
| 78 } | 89 } |
| 79 static _throwNew(int case_clause_pos) native "FallThroughError_throwNew"; | 90 |
| 80 String toString() { | 91 final String _url; |
| 81 return "'$url': Switch case fall-through at line $line."; | 92 final int _line; |
| 82 } | |
| 83 final String url; | |
| 84 final int line; | |
| 85 } | 93 } |
| 86 | 94 |
| 87 class InternalError { | 95 class _InternalError { |
| 88 const InternalError(this._msg); | 96 const _InternalError(this._msg); |
| 89 String toString() => "InternalError: '${_msg}'"; | 97 String toString() => "InternalError: '${_msg}'"; |
| 90 final String _msg; | 98 final String _msg; |
| 91 } | 99 } |
| 92 | 100 |
| 93 | 101 |
| 94 class AbstractClassInstantiationErrorImplementation | 102 class _AbstractClassInstantiationErrorImplementation |
| 95 extends AbstractClassInstantiationError { | 103 extends AbstractClassInstantiationError { |
| 96 | 104 |
| 97 factory AbstractClassInstantiationErrorImplementation._uninstantiable() { | 105 _AbstractClassInstantiationErrorImplementation( |
| 98 throw new UnsupportedError( | 106 String className, this._url, this._line) |
| 99 "AbstractClassInstantiationError can only be allocated by the VM"); | 107 : super(className); |
| 100 } | |
| 101 | 108 |
| 102 static _throwNew(int case_clause_pos, String className) | 109 static _throwNew(int case_clause_pos, String className) |
| 103 native "AbstractClassInstantiationError_throwNew"; | 110 native "AbstractClassInstantiationError_throwNew"; |
| 104 | 111 |
| 105 String toString() { | 112 String toString() { |
| 106 return "Cannot instantiate abstract class $className: " | 113 return "Cannot instantiate abstract class $_className: " |
| 107 "url '$url' line $line"; | 114 "_url '$_url' line $_line"; |
| 108 } | 115 } |
| 109 | 116 |
| 110 final String className; | 117 final String _url; |
| 111 final String url; | 118 final int _line; |
| 112 final int line; | |
| 113 } | 119 } |
| OLD | NEW |