Skip to content

Commit

Permalink
Restrict support for binary message in the default impl of exception
Browse files Browse the repository at this point in the history
  • Loading branch information
lexmag committed Jul 4, 2015
1 parent 39f5508 commit 81f8f66
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/elixir/lib/kernel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3162,26 +3162,26 @@ defmodule Kernel do
@behaviour Exception
fields = defstruct unquote(fields)

@spec exception(String.t) :: Exception.t
def exception(msg) when is_binary(msg) do
exception(message: msg)
end

@spec exception(Keyword.t) :: Exception.t
def exception(args) when is_list(args) do
Kernel.struct(__struct__, args)
end

defoverridable exception: 1

if Map.has_key?(fields, :message) do
@spec message(Exception.t) :: String.t
def message(exception) do
exception.message
end

defoverridable message: 1

@spec exception(String.t) :: Exception.t
def exception(msg) when is_binary(msg) do
exception(message: msg)
end
end

@spec exception(Keyword.t) :: Exception.t
def exception(args) when is_list(args) do
Kernel.struct(__struct__, args)
end

defoverridable exception: 1
end
end

Expand Down

0 comments on commit 81f8f66

Please sign in to comment.