1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-03 09:49:18 +02:00

mod_http_api: Fix crash when module not enabled (for example, in CT tests)

This commit is contained in:
Badlop 2024-12-11 12:18:58 +01:00
parent 3d2036db61
commit ae238bc984

View file

@ -214,7 +214,12 @@ get_api_version([<<"v", String/binary>> | Tail], Host) ->
get_api_version([_Head | Tail], Host) ->
get_api_version(Tail, Host);
get_api_version([], Host) ->
mod_http_api_opt:default_version(Host).
try mod_http_api_opt:default_version(Host)
catch error:{module_not_loaded, ?MODULE, Host} ->
?WARNING_MSG("Using module ~p for host ~s, but it isn't configured "
"in the configuration file", [?MODULE, Host]),
?DEFAULT_API_VERSION
end.
%% ----------------
%% command handlers