fix(auth_pgsql): Add back econnrefused error clause

This commit is contained in:
Zaiming Shi 2021-01-27 19:07:34 +01:00
parent fc71285c3f
commit f42e52e84e
1 changed files with 8 additions and 0 deletions

View File

@ -56,6 +56,11 @@ pgvar(Sql, Params) ->
%% PostgreSQL Connect/Query
%%--------------------------------------------------------------------
%% Due to a bug in epgsql the caluse for `econnrefused` is not recognised by
%% dialyzer, result in this error:
%% The pattern {'error', Reason = 'econnrefused'} can never match the type ...
%% https://github.com/epgsql/epgsql/issues/246
-dialyzer([{nowarn_function, [connect/1]}]).
connect(Opts) ->
Host = proplists:get_value(host, Opts),
Username = proplists:get_value(username, Opts),
@ -64,6 +69,9 @@ connect(Opts) ->
{ok, C} ->
conn_post(C),
{ok, C};
{error, Reason = econnrefused} ->
?LOG(error, "[Postgres] Can't connect to Postgres server: Connection refused."),
{error, Reason};
{error, Reason = invalid_authorization_specification} ->
?LOG(error, "[Postgres] Can't connect to Postgres server: Invalid authorization specification."),
{error, Reason};