From d609ef44787326b806101452e9a0406019893580 Mon Sep 17 00:00:00 2001 From: Robert Newson Date: Fri, 12 Aug 2011 11:55:06 +0100 Subject: [PATCH] Handling missing docs when using 'linked documents' fabric_view:possibly_embed_doc assumes the referenced doc exists and throws badmatch if not. So I fixed that. BugzID: 12535 --- src/fabric_view.erl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/fabric_view.erl b/src/fabric_view.erl index bf40a02..dc49df4 100644 --- a/src/fabric_view.erl +++ b/src/fabric_view.erl @@ -164,11 +164,14 @@ possibly_embed_doc(#collector{db_name=DbName, query_args=Args}, % to not interfere with current call {Pid, Ref} = spawn_monitor(fun() -> exit(fabric:open_doc(DbName, IncId, [])) end), - {ok, NewDoc} = - receive {'DOWN',Ref,process,Pid, Resp} -> + case receive {'DOWN',Ref,process,Pid, Resp} -> Resp - end, - Row#view_row{doc=couch_doc:to_json_obj(NewDoc,[])} + end of + {ok, NewDoc} -> + Row#view_row{doc=couch_doc:to_json_obj(NewDoc,[])}; + {not_found, missing} -> + Row#view_row{doc=null} + end end; _ -> Row end.