Skip to content

Commit

Permalink
Improve Exn.EncodeError implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
yrashk committed Oct 12, 2012
1 parent 57dac74 commit 7c22f68
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/encoder.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
defexception Exn.EncodeError, message: nil, value: nil
defexception Exn.EncodeError, value: nil do
def message(term) when is_reference(term), do: "References can't be encoded"
def message(term), do: "#{inspect term} can't be encoded"
end

defprotocol Exn.Encoder do
def encode(term)
Expand Down Expand Up @@ -28,7 +31,7 @@ defimpl Exn.Encoder, for: PID do
end

defimpl Exn.Encoder, for: Reference do
def encode(term), do: raise Exn.EncodeError, message: "References can't be encoded", value: term
def encode(term), do: raise Exn.EncodeError, value: term
end

defimpl Exn.Encoder, for: Any do
Expand Down

0 comments on commit 7c22f68

Please sign in to comment.