Skip to content

Commit

Permalink
Fix Elixir 1.15.0 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
mneudert committed Aug 23, 2023
1 parent 83c9669 commit 025e8cb
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions lib/instream/connection/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -302,21 +302,42 @@ defmodule Instream.Connection.Config do
Will issue a warning if potential misconfiguration is found.
"""
@spec validate(conn :: module) :: boolean
def validate(conn) do
with otp_app when not is_nil(otp_app) <- conn.config(:otp_app),
nil <- Application.get_env(otp_app, conn) do
_ =
Logger.warn("""
Instream connection #{inspect(conn)} is configured to fetch its
configuration from the application #{inspect(otp_app)} but the
configuration is empty.
If this is intended please set any value (except "nil") explicitly.
""")

false
else
_ -> true

if macro_exported?(Logger, :warning, 1) do
def validate(conn) do
with otp_app when not is_nil(otp_app) <- conn.config(:otp_app),
nil <- Application.get_env(otp_app, conn) do
_ =
Logger.warning("""
Instream connection #{inspect(conn)} is configured to fetch its
configuration from the application #{inspect(otp_app)} but the
configuration is empty.
If this is intended please set any value (except "nil") explicitly.
""")

false
else
_ -> true
end
end
else
def validate(conn) do
with otp_app when not is_nil(otp_app) <- conn.config(:otp_app),
nil <- Application.get_env(otp_app, conn) do
_ =
Logger.warn("""
Instream connection #{inspect(conn)} is configured to fetch its
configuration from the application #{inspect(otp_app)} but the
configuration is empty.
If this is intended please set any value (except "nil") explicitly.
""")

false
else
_ -> true
end
end
end
end

0 comments on commit 025e8cb

Please sign in to comment.