Просмотр исходного кода

fix(auth_pgsql): Add back econnrefused error clause

Zaiming Shi 5 лет назад
Родитель
Сommit
f42e52e84e
1 измененных файлов с 8 добавлено и 0 удалено
  1. 8 0
      apps/emqx_auth_pgsql/src/emqx_auth_pgsql_cli.erl

+ 8 - 0
apps/emqx_auth_pgsql/src/emqx_auth_pgsql_cli.erl

@@ -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};