check_address from rabbitmq

RabbitMQ のコードを写経してました。list_to_ipaddress です。

check_address(Host, Port) ->
  IPAddress =
    case inet:getaddr(Host, inet) of
      {ok, IPAddress1} ->
        IPAddress1;
      {error, Reason} ->
        error_logger:error_msg("invalid port ~p: ~p\n", [Host, Reason]),
        throw({error, {invalid_host, Host, Reason}})
    end,
  if
    is_integer(Port) andalso (Port >= 0) andalso (Port =< 65535) ->
      ok;
    true ->
      error_logger:error_msg("invalid port ~p: not 0..65535\n", [Port]),
      throw({error, {invalid_port, Port}})
  end,
  {IPAddress, Port}.