| 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 implements AssertionError { |
| 8 factory AssertionErrorImplementation._uninstantiable() { | 8 factory AssertionErrorImplementation._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 "'$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 TypeError extends AssertionErrorImplementation { | 24 class TypeErrorImplementation |
| 25 factory TypeError._uninstantiable() { | 25 extends AssertionErrorImplementation |
| 26 implements TypeError { |
| 27 factory TypeErrorImplementation._uninstantiable() { |
| 26 throw const UnsupportedOperationException( | 28 throw const UnsupportedOperationException( |
| 27 "TypeError can only be allocated by the VM"); | 29 "TypeError can only be allocated by the VM"); |
| 28 } | 30 } |
| 29 static _throwNew(int location, | 31 static _throwNew(int location, |
| 30 Object src_value, | 32 Object src_value, |
| 31 String dst_type_name, | 33 String dst_type_name, |
| 32 String dst_name, | 34 String dst_name, |
| 33 String malformed_error) | 35 String malformed_error) |
| 34 native "TypeError_throwNew"; | 36 native "TypeError_throwNew"; |
| 35 String toString() { | 37 String toString() { |
| 36 String str = (malformedError != null) ? malformedError : ""; | 38 String str = (malformedError != null) ? malformedError : ""; |
| 37 if ((dstName != null) && (dstName.length > 0)) { | 39 if ((dstName != null) && (dstName.length > 0)) { |
| 38 str = "${str}type '$srcType' is not a subtype of " | 40 str = "${str}type '$srcType' is not a subtype of " |
| 39 "type '$dstType' of '$dstName'."; | 41 "type '$dstType' of '$dstName'."; |
| 40 } else { | 42 } else { |
| 41 str = "${str}malformed type used."; | 43 str = "${str}malformed type used."; |
| 42 } | 44 } |
| 43 return str; | 45 return str; |
| 44 } | 46 } |
| 45 final String srcType; | 47 final String srcType; |
| 46 final String dstType; | 48 final String dstType; |
| 47 final String dstName; | 49 final String dstName; |
| 48 final String malformedError; | 50 final String malformedError; |
| 49 } | 51 } |
| 50 | 52 |
| 51 class CastException extends TypeError { | 53 class CastExceptionImplementation |
| 54 extends TypeErrorImplementation |
| 55 implements CastException { |
| 52 factory CastException._uninstantiable() { | 56 factory CastException._uninstantiable() { |
| 53 throw const UnsupportedOperationException( | 57 throw const UnsupportedOperationException( |
| 54 "CastException can only be allocated by the VM"); | 58 "CastException can only be allocated by the VM"); |
| 55 } | 59 } |
| 56 // A CastException is allocated by TypeError._throwNew() when dst_name equals | 60 // A CastException is allocated by TypeError._throwNew() when dst_name equals |
| 57 // Exceptions::kCastExceptionDstName. | 61 // Exceptions::kCastExceptionDstName. |
| 58 String toString() { | 62 String toString() { |
| 59 String str = (malformedError != null) ? malformedError : ""; | 63 String str = (malformedError != null) ? malformedError : ""; |
| 60 if ((dstName != null) && (dstName.length > 0)) { | 64 if ((dstName != null) && (dstName.length > 0)) { |
| 61 str = "${str}type '$srcType' is not a subtype of " | 65 str = "${str}type '$srcType' is not a subtype of " |
| 62 "type '$dstType' in type cast."; | 66 "type '$dstType' in type cast."; |
| 63 } else { | 67 } else { |
| 64 str = "${str}malformed type used in type cast."; | 68 str = "${str}malformed type used in type cast."; |
| 65 } | 69 } |
| 66 return str; | 70 return str; |
| 67 } | 71 } |
| 68 } | 72 } |
| 69 | 73 |
| 70 class FallThroughError { | 74 class FallThroughErrorImplementation implements FallThroughError { |
| 71 factory FallThroughError._uninstantiable() { | 75 factory FallThroughErrorImplementation._uninstantiable() { |
| 72 throw const UnsupportedOperationException( | 76 throw const UnsupportedOperationException( |
| 73 "FallThroughError can only be allocated by the VM"); | 77 "FallThroughError can only be allocated by the VM"); |
| 74 } | 78 } |
| 75 static _throwNew(int case_clause_pos) native "FallThroughError_throwNew"; | 79 static _throwNew(int case_clause_pos) native "FallThroughError_throwNew"; |
| 76 String toString() { | 80 String toString() { |
| 77 return "'$url': Switch case fall-through at line $line."; | 81 return "'$url': Switch case fall-through at line $line."; |
| 78 } | 82 } |
| 79 final String url; | 83 final String url; |
| 80 final int line; | 84 final int line; |
| 81 } | 85 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 96 String toString() => "Unresolved static method: url '$url' line $line " | 100 String toString() => "Unresolved static method: url '$url' line $line " |
| 97 "pos $column\n$failedResolutionLine\n"; | 101 "pos $column\n$failedResolutionLine\n"; |
| 98 | 102 |
| 99 static _throwNew(int token_pos) native "StaticResolutionException_throwNew"; | 103 static _throwNew(int token_pos) native "StaticResolutionException_throwNew"; |
| 100 | 104 |
| 101 final String failedResolutionLine; | 105 final String failedResolutionLine; |
| 102 final String url; | 106 final String url; |
| 103 final int line; | 107 final int line; |
| 104 final int column; | 108 final int column; |
| 105 } | 109 } |
| OLD | NEW |