diff options
author | John Christopher Anderson <jchris@apache.org> | 2009-04-16 06:02:12 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2009-04-16 06:02:12 +0000 |
commit | 47edd9d102446e0b0b661d7cc4a7b46eae6a9a5e (patch) | |
tree | c34a44976387d531487ce430718b97c85a945a2a /src/couchdb/couch_os_process.erl | |
parent | f5298dec9cb5ed763b73e47d4484bc2023a59a55 (diff) |
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
Diffstat (limited to 'src/couchdb/couch_os_process.erl')
-rw-r--r-- | src/couchdb/couch_os_process.erl | 16 |
1 files changed, 14 insertions, 2 deletions
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, |