File 3206-erl_docgen-Better-missing-module-fault-indication.patch of Package erlang
From 2568aeae8a4bcd2180b7db55c04d4c37d4df9f5e Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Wed, 17 Nov 2021 13:43:00 +0100
Subject: [PATCH 6/7] erl_docgen: Better missing module fault indication
If the app or module are incorrect we should return a nice
printout and not just crash when runnig make xmllint
---
.../priv/bin/validate_links.escript | 21 ++++++++++++-------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/lib/erl_docgen/priv/bin/validate_links.escript b/lib/erl_docgen/priv/bin/validate_links.escript
index a11350ad2f..db368bea73 100755
--- a/lib/erl_docgen/priv/bin/validate_links.escript
+++ b/lib/erl_docgen/priv/bin/validate_links.escript
@@ -231,14 +231,19 @@ validate_link(Filename, "seemfa", Line, Link, CachedFiles) ->
try list_to_integer(Arity) of
_ ->
MF = App ++ ":" ++ Mod ++ "#" ++ Func,
- Funcs = maps:get(funcs,maps:get({App,Mod},CachedFiles)),
- case lists:member({Func,Arity},Funcs) of
- true ->
- validate_type(Line, "seemfa",
- read_link(Line, ParsedLink, CachedFiles));
- false ->
- fail(Line, "Could not find documentation for ~s when "
- "resolving link",[MF ++ "/" ++ Arity])
+ case maps:find({App,Mod},CachedFiles) of
+ error ->
+ fail(Line, "Could not find ~ts in ~ts", [Mod, App]);
+ {ok, ModInfo} ->
+ Funcs = maps:get(funcs,ModInfo),
+ case lists:member({Func,Arity},Funcs) of
+ true ->
+ validate_type(Line, "seemfa",
+ read_link(Line, ParsedLink, CachedFiles));
+ false ->
+ fail(Line, "Could not find documentation for ~s when "
+ "resolving link",[MF ++ "/" ++ Arity])
+ end
end
catch _:_ ->
fail(Line, "Invalid arity for seemfa. "
--
2.31.1