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

Side by Side Diff: runtime/lib/errors.cc

Issue 1778133002: Enumerate URIs of all types in type errors in order to help the user diagnose (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments Created 4 years, 9 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
« no previous file with comments | « no previous file | runtime/lib/errors_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4
5 #include "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 #include "vm/exceptions.h" 6 #include "vm/exceptions.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/runtime_entry.h" 8 #include "vm/runtime_entry.h"
9 #include "vm/stack_frame.h" 9 #include "vm/stack_frame.h"
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 Exceptions::ThrowByType(Exceptions::kAssertion, args); 47 Exceptions::ThrowByType(Exceptions::kAssertion, args);
48 UNREACHABLE(); 48 UNREACHABLE();
49 return Object::null(); 49 return Object::null();
50 } 50 }
51 51
52 52
53 // Allocate and throw a new TypeError or CastError. 53 // Allocate and throw a new TypeError or CastError.
54 // Arg0: index of the token of the failed type check. 54 // Arg0: index of the token of the failed type check.
55 // Arg1: src value. 55 // Arg1: src value.
56 // Arg2: dst type name. 56 // Arg2: dst type.
57 // Arg3: dst name. 57 // Arg3: dst name.
58 // Arg4: type error message. 58 // Arg4: type error message.
59 // Return value: none, throws an exception. 59 // Return value: none, throws an exception.
60 DEFINE_NATIVE_ENTRY(TypeError_throwNew, 5) { 60 DEFINE_NATIVE_ENTRY(TypeError_throwNew, 5) {
61 // No need to type check the arguments. This function can only be called 61 // No need to type check the arguments. This function can only be called
62 // internally from the VM. 62 // internally from the VM.
63 const TokenPosition location = 63 const TokenPosition location =
64 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(0)).Value()); 64 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(0)).Value());
65 const Instance& src_value = 65 const Instance& src_value =
66 Instance::CheckedHandle(arguments->NativeArgAt(1)); 66 Instance::CheckedHandle(arguments->NativeArgAt(1));
67 const String& dst_type_name = 67 const AbstractType& dst_type =
68 String::CheckedHandle(arguments->NativeArgAt(2)); 68 AbstractType::CheckedHandle(arguments->NativeArgAt(2));
69 const String& dst_name = String::CheckedHandle(arguments->NativeArgAt(3)); 69 const String& dst_name = String::CheckedHandle(arguments->NativeArgAt(3));
70 const String& error_msg = String::CheckedHandle(arguments->NativeArgAt(4)); 70 const String& error_msg = String::CheckedHandle(arguments->NativeArgAt(4));
71 const String& src_type_name = String::Handle( 71 const AbstractType& src_type = AbstractType::Handle(src_value.GetType());
72 AbstractType::Handle(src_value.GetType()).UserVisibleName()); 72 Exceptions::CreateAndThrowTypeError(
73 Exceptions::CreateAndThrowTypeError(location, src_type_name, 73 location, src_type, dst_type, dst_name, error_msg);
74 dst_type_name, dst_name, error_msg);
75 UNREACHABLE(); 74 UNREACHABLE();
76 return Object::null(); 75 return Object::null();
77 } 76 }
78 77
79 78
80 // Allocate and throw a new FallThroughError. 79 // Allocate and throw a new FallThroughError.
81 // Arg0: index of the case clause token into which we fall through. 80 // Arg0: index of the case clause token into which we fall through.
82 // Return value: none, throws an exception. 81 // Return value: none, throws an exception.
83 DEFINE_NATIVE_ENTRY(FallThroughError_throwNew, 1) { 82 DEFINE_NATIVE_ENTRY(FallThroughError_throwNew, 1) {
84 GET_NON_NULL_NATIVE_ARGUMENT(Smi, smi_pos, arguments->NativeArgAt(0)); 83 GET_NON_NULL_NATIVE_ARGUMENT(Smi, smi_pos, arguments->NativeArgAt(0));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 128
130 // Rethrow an error with a stacktrace. 129 // Rethrow an error with a stacktrace.
131 DEFINE_NATIVE_ENTRY(Async_rethrow, 2) { 130 DEFINE_NATIVE_ENTRY(Async_rethrow, 2) {
132 GET_NON_NULL_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(0)); 131 GET_NON_NULL_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(0));
133 GET_NON_NULL_NATIVE_ARGUMENT(Instance, stacktrace, arguments->NativeArgAt(1)); 132 GET_NON_NULL_NATIVE_ARGUMENT(Instance, stacktrace, arguments->NativeArgAt(1));
134 Exceptions::ReThrow(thread, error, stacktrace); 133 Exceptions::ReThrow(thread, error, stacktrace);
135 return Object::null(); 134 return Object::null();
136 } 135 }
137 136
138 } // namespace dart 137 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/errors_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698