Skip to content

Commit

Permalink
Fix bitwalker#398 - handle FormatError with non-string reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwalker committed May 8, 2018
1 parent 0f5a508 commit 0fc554e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/format/format_error.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ defmodule Timex.Format.FormatError do
@moduledoc """
Used for errors encountered during string formatting.
"""
alias Timex.Format.FormatError

defexception message: "Invalid format!"

def exception([message: message]) when is_binary(message) do
%__MODULE__{message: message}
end
def exception([message: message]) do
%FormatError{message: message}
%__MODULE__{message: "Invalid format: #{inspect message}"}
end
def exception(err) do
%__MODULE__{message: "Invalid format: #{inspect err}"}
end
end

0 comments on commit 0fc554e

Please sign in to comment.