Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: runtime/lib/error.dart

Issue 10896007: Expose remaining 'errors' in an unified dart:core. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make all implementations implement, not extend, the exposed type. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698