Index: src/value-serializer.cc |
diff --git a/src/value-serializer.cc b/src/value-serializer.cc |
index 7752a47efa14394ab40313f487aa7fdf79e6fd82..79e2b7382a55c19a83b321c643dba94a36dc6a86 100644 |
--- a/src/value-serializer.cc |
+++ b/src/value-serializer.cc |
@@ -1849,6 +1849,20 @@ static Maybe<bool> SetPropertiesFromKeyValuePairs(Isolate* isolate, |
return Just(true); |
} |
+namespace { |
+ |
+// Throws a generic "deserialization failed" exception by default, unless a more |
+// specific exception has already been thrown. |
+void ThrowDeserializationExceptionIfNonePending(Isolate* isolate) { |
+ if (!isolate->has_pending_exception()) { |
+ isolate->Throw(*isolate->factory()->NewError( |
+ MessageTemplate::kDataCloneDeserializationError)); |
+ } |
+ DCHECK(isolate->has_pending_exception()); |
+} |
+ |
+} // namespace |
+ |
MaybeHandle<Object> |
ValueDeserializer::ReadObjectUsingEntireBufferForLegacyFormat() { |
DCHECK_EQ(version_, 0u); |
@@ -1881,7 +1895,7 @@ ValueDeserializer::ReadObjectUsingEntireBufferForLegacyFormat() { |
!SetPropertiesFromKeyValuePairs( |
isolate_, js_object, &stack[begin_properties], num_properties) |
.FromMaybe(false)) { |
- DCHECK(isolate_->has_pending_exception()); |
+ ThrowDeserializationExceptionIfNonePending(isolate_); |
return MaybeHandle<Object>(); |
} |
@@ -1912,7 +1926,7 @@ ValueDeserializer::ReadObjectUsingEntireBufferForLegacyFormat() { |
!SetPropertiesFromKeyValuePairs( |
isolate_, js_array, &stack[begin_properties], num_properties) |
.FromMaybe(false)) { |
- DCHECK(isolate_->has_pending_exception()); |
+ ThrowDeserializationExceptionIfNonePending(isolate_); |
return MaybeHandle<Object>(); |
} |