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

Side by Side Diff: src/messages.cc

Issue 2870423002: [error] Clear external_caught_exception in Error formatting (Closed)
Patch Set: Add test Created 3 years, 7 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 | test/mjsunit/regress/regress-719380.js » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/messages.h" 5 #include "src/messages.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/execution.h" 10 #include "src/execution.h"
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 MaybeHandle<String> err_str = 883 MaybeHandle<String> err_str =
884 ErrorUtils::ToString(isolate, Handle<Object>::cast(error)); 884 ErrorUtils::ToString(isolate, Handle<Object>::cast(error));
885 if (err_str.is_null()) { 885 if (err_str.is_null()) {
886 // Error.toString threw. Try to return a string representation of the thrown 886 // Error.toString threw. Try to return a string representation of the thrown
887 // exception instead. 887 // exception instead.
888 888
889 DCHECK(isolate->has_pending_exception()); 889 DCHECK(isolate->has_pending_exception());
890 Handle<Object> pending_exception = 890 Handle<Object> pending_exception =
891 handle(isolate->pending_exception(), isolate); 891 handle(isolate->pending_exception(), isolate);
892 isolate->clear_pending_exception(); 892 isolate->clear_pending_exception();
893 isolate->set_external_caught_exception(false);
893 894
894 err_str = ErrorUtils::ToString(isolate, pending_exception); 895 err_str = ErrorUtils::ToString(isolate, pending_exception);
895 if (err_str.is_null()) { 896 if (err_str.is_null()) {
896 // Formatting the thrown exception threw again, give up. 897 // Formatting the thrown exception threw again, give up.
897 DCHECK(isolate->has_pending_exception()); 898 DCHECK(isolate->has_pending_exception());
898 isolate->clear_pending_exception(); 899 isolate->clear_pending_exception();
899 900 isolate->set_external_caught_exception(false);
900 builder->AppendCString("<error>"); 901 builder->AppendCString("<error>");
901 } else { 902 } else {
902 // Formatted thrown exception successfully, append it. 903 // Formatted thrown exception successfully, append it.
903 builder->AppendCString("<error: "); 904 builder->AppendCString("<error: ");
904 builder->AppendString(err_str.ToHandleChecked()); 905 builder->AppendString(err_str.ToHandleChecked());
905 builder->AppendCharacter('>'); 906 builder->AppendCharacter('>');
906 } 907 }
907 } else { 908 } else {
908 builder->AppendString(err_str.ToHandleChecked()); 909 builder->AppendString(err_str.ToHandleChecked());
909 } 910 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 StackFrameBase* frame = it.Frame(); 985 StackFrameBase* frame = it.Frame();
985 MaybeHandle<String> maybe_frame_string = frame->ToString(); 986 MaybeHandle<String> maybe_frame_string = frame->ToString();
986 if (maybe_frame_string.is_null()) { 987 if (maybe_frame_string.is_null()) {
987 // CallSite.toString threw. Try to return a string representation of the 988 // CallSite.toString threw. Try to return a string representation of the
988 // thrown exception instead. 989 // thrown exception instead.
989 990
990 DCHECK(isolate->has_pending_exception()); 991 DCHECK(isolate->has_pending_exception());
991 Handle<Object> pending_exception = 992 Handle<Object> pending_exception =
992 handle(isolate->pending_exception(), isolate); 993 handle(isolate->pending_exception(), isolate);
993 isolate->clear_pending_exception(); 994 isolate->clear_pending_exception();
995 isolate->set_external_caught_exception(false);
994 996
995 maybe_frame_string = ErrorUtils::ToString(isolate, pending_exception); 997 maybe_frame_string = ErrorUtils::ToString(isolate, pending_exception);
996 if (maybe_frame_string.is_null()) { 998 if (maybe_frame_string.is_null()) {
997 // Formatting the thrown exception threw again, give up. 999 // Formatting the thrown exception threw again, give up.
998 1000
999 builder.AppendCString("<error>"); 1001 builder.AppendCString("<error>");
1000 } else { 1002 } else {
1001 // Formatted thrown exception successfully, append it. 1003 // Formatted thrown exception successfully, append it.
1002 builder.AppendCString("<error: "); 1004 builder.AppendCString("<error: ");
1003 builder.AppendString(maybe_frame_string.ToHandleChecked()); 1005 builder.AppendString(maybe_frame_string.ToHandleChecked());
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 Handle<String> arg2_str = Object::NoSideEffectsToString(isolate, arg2); 1217 Handle<String> arg2_str = Object::NoSideEffectsToString(isolate, arg2);
1216 1218
1217 isolate->native_context()->IncrementErrorsThrown(); 1219 isolate->native_context()->IncrementErrorsThrown();
1218 1220
1219 Handle<String> msg; 1221 Handle<String> msg;
1220 if (!MessageTemplate::FormatMessage(template_index, arg0_str, arg1_str, 1222 if (!MessageTemplate::FormatMessage(template_index, arg0_str, arg1_str,
1221 arg2_str) 1223 arg2_str)
1222 .ToHandle(&msg)) { 1224 .ToHandle(&msg)) {
1223 DCHECK(isolate->has_pending_exception()); 1225 DCHECK(isolate->has_pending_exception());
1224 isolate->clear_pending_exception(); 1226 isolate->clear_pending_exception();
1227 isolate->set_external_caught_exception(false);
1225 return isolate->factory()->NewStringFromAsciiChecked("<error>"); 1228 return isolate->factory()->NewStringFromAsciiChecked("<error>");
1226 } 1229 }
1227 1230
1228 return msg; 1231 return msg;
1229 } 1232 }
1230 1233
1231 } // namespace 1234 } // namespace
1232 1235
1233 // static 1236 // static
1234 MaybeHandle<Object> ErrorUtils::MakeGenericError( 1237 MaybeHandle<Object> ErrorUtils::MakeGenericError(
(...skipping 11 matching lines...) Expand all
1246 DCHECK(mode != SKIP_UNTIL_SEEN); 1249 DCHECK(mode != SKIP_UNTIL_SEEN);
1247 1250
1248 Handle<Object> no_caller; 1251 Handle<Object> no_caller;
1249 Handle<String> msg = FormatMessage(isolate, template_index, arg0, arg1, arg2); 1252 Handle<String> msg = FormatMessage(isolate, template_index, arg0, arg1, arg2);
1250 return ErrorUtils::Construct(isolate, constructor, constructor, msg, mode, 1253 return ErrorUtils::Construct(isolate, constructor, constructor, msg, mode,
1251 no_caller, false); 1254 no_caller, false);
1252 } 1255 }
1253 1256
1254 } // namespace internal 1257 } // namespace internal
1255 } // namespace v8 1258 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-719380.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698