2009-06-25 Jian Li <jianli@chromium.org>
[WebKit-https.git] / WebCore / bindings / v8 / WorkerScriptController.cpp
index cf2a186..d418184 100644 (file)
@@ -68,14 +68,20 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode)
     }
 
     v8::Local<v8::Value> result = m_proxy->evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startLine() - 1);
-    m_workerContext->thread()->workerObjectProxy()->reportPendingActivity(m_workerContext->hasPendingActivity());
+    m_workerContext->thread()->workerObjectProxy().reportPendingActivity(m_workerContext->hasPendingActivity());
     return ScriptValue();
 }
 
-ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, ScriptValue* /* exception */)
+ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, ScriptValue* exception)
 {
-    // FIXME: Need to return an exception.
-    return evaluate(sourceCode);
+    v8::TryCatch exceptionCatcher;
+    ScriptValue result = evaluate(sourceCode);
+    if (exceptionCatcher.HasCaught()) {
+        *exception = ScriptValue(exceptionCatcher.Exception());
+        throwError(exceptionCatcher.Exception());
+        return ScriptValue();
+    } else
+        return result;
 }
 
 void WorkerScriptController::forbidExecution()