-
- Vector<StackFrame> stackTrace;
- interpreter->getStackTrace(stackTrace);
- m_exceptionStack = RefCountedArray<StackFrame>(stackTrace);
- m_exception = error;
-
- if (stackTrace.isEmpty() || !error.isObject())
- return error;
- JSObject* exception = asObject(error);
-
- StackFrame stackFrame;
- for (unsigned i = 0 ; i < stackTrace.size(); ++i) {
- stackFrame = stackTrace.at(i);
- if (stackFrame.bytecodeOffset)
- break;
- }
- unsigned bytecodeOffset = stackFrame.bytecodeOffset;
- if (!hasErrorInfo(exec, exception)) {
- // FIXME: We should only really be adding these properties to VM generated exceptions,
- // but the inspector currently requires these for all thrown objects.
- unsigned line;
- unsigned column;
- stackFrame.computeLineAndColumn(line, column);
- exception->putDirect(*this, Identifier(this, "line"), jsNumber(line), ReadOnly | DontDelete);
- exception->putDirect(*this, Identifier(this, "column"), jsNumber(column), ReadOnly | DontDelete);
- if (!stackFrame.sourceURL.isEmpty())
- exception->putDirect(*this, Identifier(this, "sourceURL"), jsString(this, stackFrame.sourceURL), ReadOnly | DontDelete);
- }
- if (exception->isErrorInstance() && static_cast<ErrorInstance*>(exception)->appendSourceToMessage()) {
- unsigned stackIndex = 0;
- CallFrame* callFrame;
- for (callFrame = exec; callFrame && !callFrame->codeBlock(); ) {
- stackIndex++;
- callFrame = callFrame->callerFrameSkippingVMEntrySentinel();
- }
- if (callFrame && callFrame->codeBlock()) {
- stackFrame = stackTrace.at(stackIndex);
- bytecodeOffset = stackFrame.bytecodeOffset;
- appendSourceToError(callFrame, static_cast<ErrorInstance*>(exception), bytecodeOffset);
- }
- }
-
- if (exception->hasProperty(exec, this->propertyNames->stack))
- return error;
-
- exception->putDirect(*this, propertyNames->stack, interpreter->stackTraceAsString(topCallFrame, stackTrace), DontEnum);
- return error;
-}
-
-JSObject* VM::throwException(ExecState* exec, JSObject* error)
-{
- return asObject(throwException(exec, JSValue(error)));
-}
-void VM::getExceptionInfo(JSValue& exception, RefCountedArray<StackFrame>& exceptionStack)
-{
- exception = m_exception;
- exceptionStack = m_exceptionStack;
-}
-void VM::setExceptionInfo(JSValue& exception, RefCountedArray<StackFrame>& exceptionStack)
-{
- m_exception = exception;
- m_exceptionStack = exceptionStack;