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

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

Issue 21832003: Fix VM implementation of CastError not to extend TypeError (issue 5280). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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
« no previous file with comments | « runtime/lib/error.cc ('k') | runtime/lib/errors.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 // Errors are created and thrown by DartVM only.
5 // Changes here should also be reflected in corelib/error.dart as well
6
7 class _AssertionErrorImplementation extends AssertionError {
8 _AssertionErrorImplementation(
9 this.failedAssertion, this.url, this.line, this.column);
10
11 static _throwNew(int assertionStart, int assertionEnd)
12 native "AssertionError_throwNew";
13
14 String toString() {
15 return "'$url': Failed assertion: line $line pos $column: "
16 "'$failedAssertion' is not true.";
17 }
18 final String failedAssertion;
19 final String url;
20 final int line;
21 final int column;
22 }
23
24 class _TypeErrorImplementation
25 extends _AssertionErrorImplementation
26 implements TypeError {
27
28 _TypeErrorImplementation(
29 String failedAssertion, String url, int line, int column,
30 this.srcType, this.dstType, this.dstName, this._malformedError)
31 : super(failedAssertion, url, line, column);
32
33 static _throwNew(int location,
34 Object src_value,
35 String dst_type_name,
36 String dst_name,
37 String malformed_error)
38 native "TypeError_throwNew";
39
40 String toString() {
41 String str = (_malformedError != null) ? _malformedError : "";
42 if ((dstName != null) && (dstName.length > 0)) {
43 str = "${str}type '$srcType' is not a subtype of "
44 "type '$dstType' of '$dstName'.";
45 } else {
46 str = "${str}malformed type used.";
47 }
48 return str;
49 }
50
51 final String srcType;
52 final String dstType;
53 final String dstName;
54 final String _malformedError;
55 }
56
57 class _CastErrorImplementation
58 extends _TypeErrorImplementation
59 implements CastError {
60
61 _CastErrorImplementation(
62 String failedAssertion, String url, int line, int column,
63 String srcType, String dstType, String dstName, String malformedError)
64 : super(failedAssertion, url, line, column,
65 srcType, dstType, dstName, malformedError);
66
67 // A CastError is allocated by TypeError._throwNew() when dst_name equals
68 // Exceptions::kCastErrorDstName.
69 String toString() {
70 String str = (_malformedError != null) ? _malformedError : "";
71 if ((dstName != null) && (dstName.length > 0)) {
72 str = "${str}type '$srcType' is not a subtype of "
73 "type '$dstType' in type cast.";
74 } else {
75 str = "${str}malformed type used in type cast.";
76 }
77 return str;
78 }
79 }
80
81 class _FallThroughErrorImplementation extends FallThroughError {
82
83 _FallThroughErrorImplementation(this._url, this._line);
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.";
89 }
90
91 final String _url;
92 final int _line;
93 }
94
95 class _InternalError {
96 const _InternalError(this._msg);
97 String toString() => "InternalError: '${_msg}'";
98 final String _msg;
99 }
100
101
102 class _AbstractClassInstantiationErrorImplementation
103 extends AbstractClassInstantiationError {
104
105 _AbstractClassInstantiationErrorImplementation(
106 String className, this._url, this._line)
107 : super(className);
108
109 static _throwNew(int case_clause_pos, String className)
110 native "AbstractClassInstantiationError_throwNew";
111
112 String toString() {
113 return "Cannot instantiate abstract class $_className: "
114 "_url '$_url' line $_line";
115 }
116
117 final String _url;
118 final int _line;
119 }
OLDNEW
« no previous file with comments | « runtime/lib/error.cc ('k') | runtime/lib/errors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698