| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 AssertionError { | 7 class AssertionError { |
| 8 factory AssertionError._uninstantiable() { | 8 factory AssertionError._uninstantiable() { |
| 9 throw const UnsupportedOperationException( | 9 throw const UnsupportedOperationException( |
| 10 "AssertionError can only be allocated by the VM"); | 10 "AssertionError can only be allocated by the VM"); |
| 11 } | 11 } |
| 12 static _throwNew(int assertionStart, int assertionEnd) | 12 static _throwNew(int assertionStart, int assertionEnd) |
| 13 native "AssertionError_throwNew"; | 13 native "AssertionError_throwNew"; |
| 14 String toString() { | 14 String toString() { |
| 15 return "Failed assertion: '$failedAssertion' is not true " + | 15 return "'$url': Failed assertion: line $line pos $column: " + |
| 16 "in $url at line $line, column $column."; | 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 TypeError extends AssertionError { | 24 class TypeError extends AssertionError { |
| 25 factory TypeError._uninstantiable() { | 25 factory TypeError._uninstantiable() { |
| 26 throw const UnsupportedOperationException( | 26 throw const UnsupportedOperationException( |
| 27 "TypeError can only be allocated by the VM"); | 27 "TypeError can only be allocated by the VM"); |
| 28 } | 28 } |
| 29 String toString() { | 29 String toString() { |
| 30 return "Failed type check: type $srcType is not assignable to type " + | 30 return "'$url': Failed type check: line $line pos $column: " + |
| 31 "$dstType of $dstName in $url at line " + | 31 "type '$srcType' is not assignable to type '$dstType' of '$dstName'."; |
| 32 "$line, column $column."; | |
| 33 } | 32 } |
| 34 final String srcType; | 33 final String srcType; |
| 35 final String dstType; | 34 final String dstType; |
| 36 final String dstName; | 35 final String dstName; |
| 37 } | 36 } |
| 38 | 37 |
| 39 class FallThroughError { | 38 class FallThroughError { |
| 40 factory FallThroughError._uninstantiable() { | 39 factory FallThroughError._uninstantiable() { |
| 41 throw const UnsupportedOperationException( | 40 throw const UnsupportedOperationException( |
| 42 "FallThroughError can only be allocated by the VM"); | 41 "FallThroughError can only be allocated by the VM"); |
| 43 } | 42 } |
| 44 static _throwNew(int case_clause_pos) native "FallThroughError_throwNew"; | 43 static _throwNew(int case_clause_pos) native "FallThroughError_throwNew"; |
| 45 String toString() { | 44 String toString() { |
| 46 return "Switch case fall-through in $url at line $line."; | 45 return "'$url': Switch case fall-through at line $line."; |
| 47 } | 46 } |
| 48 final String url; | 47 final String url; |
| 49 final int line; | 48 final int line; |
| 50 } | 49 } |
| 51 | 50 |
| 52 class InternalError { | 51 class InternalError { |
| 53 const InternalError(this._msg); | 52 const InternalError(this._msg); |
| 54 String toString() => "InternalError: '${_msg}'"; | 53 String toString() => "InternalError: '${_msg}'"; |
| 55 final String _msg; | 54 final String _msg; |
| 56 } | 55 } |
| OLD | NEW |