From 47edd9d102446e0b0b661d7cc4a7b46eae6a9a5e Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Thu, 16 Apr 2009 06:02:12 +0000 Subject: Baby steps toward better reporting of os_process errors (and JavaScript syntax errors) git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@765479 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_os_process.erl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/couchdb/couch_os_process.erl') 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, -- cgit v1.2.3