Files
api-v2/deps/db_connection/lib/db_connection/connection_error.ex
2025-04-16 10:03:13 -03:00

25 lines
662 B
Elixir

defmodule DBConnection.ConnectionError do
@moduledoc """
A generic connection error exception.
The raised exception might include the reason which would be useful
to programmatically determine what was causing the error.
"""
@typedoc since: "2.7.0"
@type t() :: %__MODULE__{
message: String.t(),
reason: :error | :queue_timeout,
severity: Logger.level()
}
defexception [:message, severity: :error, reason: :error]
@doc false
def exception(message, reason) when is_binary(message) and reason in [:error, :queue_timeout] do
message
|> exception()
|> Map.replace!(:reason, reason)
end
end