Check if Handler module exists before we try to call update
diff --git a/src/couch_epi_data.erl b/src/couch_epi_data.erl
index b685dae..502ed69 100644
--- a/src/couch_epi_data.erl
+++ b/src/couch_epi_data.erl
@@ -110,7 +110,15 @@
%% Internal Function Definitions
%% ------------------------------------------------------------------
-reload_if_updated(#state{hash = OldHash, module = Module} = State) ->
+reload_if_updated(#state{handle = Module} = State) ->
+ case couch_epi_util:module_exists(Module) of
+ true ->
+ do_reload_if_updated(State);
+ false ->
+ {ok, State}
+ end.
+
+do_reload_if_updated(#state{hash = OldHash, module = Module} = State) ->
case couch_epi_functions_gen:hash([Module]) of
OldHash ->
{ok, State};
diff --git a/src/couch_epi_data_source.erl b/src/couch_epi_data_source.erl
index f905e8f..ef83b14 100644
--- a/src/couch_epi_data_source.erl
+++ b/src/couch_epi_data_source.erl
@@ -144,7 +144,15 @@
{error, {notfound, FilePath}}
end.
-reload_if_updated(#state{hash = OldHash, locator = Locator} = State) ->
+reload_if_updated(#state{handle = Module} = State) ->
+ case couch_epi_util:module_exists(Module) of
+ true ->
+ do_reload_if_updated(State);
+ false ->
+ {ok, State}
+ end.
+
+do_reload_if_updated(#state{hash = OldHash, locator = Locator} = State) ->
case read(Locator) of
{ok, OldHash, _Data} ->
{ok, State};
diff --git a/src/couch_epi_functions.erl b/src/couch_epi_functions.erl
index 09ece2e..33c4f91 100644
--- a/src/couch_epi_functions.erl
+++ b/src/couch_epi_functions.erl
@@ -112,7 +112,15 @@
%% Internal Function Definitions
%% ------------------------------------------------------------------
-reload_if_updated(#state{hash = OldHash, modules = Modules} = State) ->
+reload_if_updated(#state{handle = Module} = State) ->
+ case couch_epi_util:module_exists(Module) of
+ true ->
+ do_reload_if_updated(State);
+ false ->
+ {ok, State}
+ end.
+
+do_reload_if_updated(#state{hash = OldHash, modules = Modules} = State) ->
case couch_epi_functions_gen:hash(Modules) of
OldHash ->
{ok, State};