Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Source/JavaScriptCore/runtime/Error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ JSObject* addErrorInfo(VM& vm, JSObject* error, int line, const SourceCode& sour
if (!sourceURL.isEmpty()) {
errorInstance->setSourceURL(sourceURL);
}

// materializeErrorInfoIfNeeded() formats the stack through the host, which reads this.
errorInstance->setHasParseLocation();
#endif

errorInstance->materializeErrorInfoIfNeeded(vm);
Expand Down
3 changes: 3 additions & 0 deletions Source/JavaScriptCore/runtime/ErrorInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ ErrorInstance::ErrorInstance(VM& vm, Structure* structure, ErrorType errorType)
#if ENABLE(WEBASSEMBLY)
, m_catchableFromWasm(true)
#endif // ENABLE(WEBASSEMBLY)
#if USE(BUN_JSC_ADDITIONS)
, m_hasParseLocation(false)
#endif
{
}

Expand Down
9 changes: 9 additions & 0 deletions Source/JavaScriptCore/runtime/ErrorInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ class ErrorInstance : public JSNonFinalObject {
void setStackFrames(VM& vm, WTF::Vector<JSC::StackFrame>&& stackFrames);
bool hasMaterializedErrorInfo() const { return m_errorInfoMaterialized; }

// Whether line()/sourceURL() were recorded by addErrorInfo() for a source the parser rejected, as
// opposed to copied from another error (structured clone) or derived from the stack frames. Unlike
// isParseError(), this is not set for parse errors that record no location (eval code), and it is
// set before the stack is materialized, so the host's stack formatter can rely on it.
bool hasParseLocation() const { return m_hasParseLocation; }
void setHasParseLocation() { m_hasParseLocation = true; }
#endif

JS_EXPORT_PRIVATE String sanitizedToString(JSGlobalObject*);
Expand Down Expand Up @@ -172,6 +178,9 @@ class ErrorInstance : public JSNonFinalObject {
#if ENABLE(WEBASSEMBLY)
bool m_catchableFromWasm : 1;
#endif
#if USE(BUN_JSC_ADDITIONS)
bool m_hasParseLocation : 1;
#endif
};

String appendSourceToErrorMessage(CodeBlock*, BytecodeIndex, const String&, RuntimeType, ErrorInstance::SourceAppender);
Expand Down
Loading