-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DBConnection.ConnectionError.t/0 type (#304)
- Loading branch information
1 parent
fa5f705
commit 8ef1f2e
Showing
2 changed files
with
24 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
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 |