diff options
-rw-r--r-- | share/server/main.js | 3 | ||||
-rw-r--r-- | src/couchdb/couch_js.c | 1 | ||||
-rw-r--r-- | src/couchdb/couch_os_process.erl | 16 |
3 files changed, 17 insertions, 3 deletions
diff --git a/share/server/main.js b/share/server/main.js index 81180678..b8612d41 100644 --- a/share/server/main.js +++ b/share/server/main.js @@ -414,7 +414,8 @@ function runRenderFunction(renderFun, args) { } catch(e) { log("function raised error: "+e.toString()); log("stacktrace: "+e.stack); - respond({error:"render_error",reason:e}); + var errorMessage = "function raised error: "+e.toString()+"\nstacktrace: "+e.stack; + respond({error:"render_error",reason:errorMessage}); } }; diff --git a/src/couchdb/couch_js.c b/src/couchdb/couch_js.c index a6fbde60..045e6c7f 100644 --- a/src/couchdb/couch_js.c +++ b/src/couchdb/couch_js.c @@ -231,6 +231,7 @@ EvalInContext(JSContext *context, JSObject *obj, uintN argc, jsval *argv, } else { ok = JS_EvaluateUCScript(sub_context, sandbox, src, srclen, NULL, -1, rval); + ok = JS_TRUE; } out: diff --git a/src/couchdb/couch_os_process.erl b/src/couchdb/couch_os_process.erl index 578017f8..9a1fcb0c 100644 --- a/src/couchdb/couch_os_process.erl +++ b/src/couchdb/couch_os_process.erl @@ -51,7 +51,13 @@ read(Pid) -> gen_server:call(Pid, read). prompt(Pid, Data) -> - gen_server:call(Pid, {prompt, Data}, infinity). + case gen_server:call(Pid, {prompt, Data}, infinity) of + {ok, Result} -> + Result; + {error, Error} -> + ?LOG_DEBUG("OS Process Error ~p",[Error]), + throw(Error) + end. async(Pid, Data, CallBack) -> gen_server:cast(Pid, {async, Data, CallBack}). @@ -138,7 +144,13 @@ handle_call(read, _From, OsProc) -> handle_call({prompt, Data}, _From, OsProc) -> #os_proc{writer=Writer, reader=Reader} = OsProc, Writer(OsProc, Data), - {reply, Reader(OsProc), OsProc}. + Result = try Reader(OsProc) of + Ok -> {ok, Ok} + catch + throw:OsError -> + {error, OsError} + end, + {reply, Result, OsProc}. handle_cast({async, Data, CallBack}, OsProc) -> #os_proc{writer=Writer, reader=Reader} = OsProc, |