File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,21 @@ defmodule Exception do
3131 @ type arity_or_args :: non_neg_integer | list
3232 @ type location :: keyword
3333
34+ @ doc """
35+ Receives the arguments given to `raise/2` and returns the exception struct.
36+
37+ The default implementation accepts either a set of keyword arguments
38+ that is merged into the struct or a string to be used as the exception's message.
39+ """
3440 @ callback exception ( term ) :: t
41+
42+ @ doc """
43+ Receives the exception struct and must return its message.
44+
45+ Most commonly exceptions have a message field which by default is accessed
46+ by this function. However, if an exception does not have a message field,
47+ this function must be explicitly implemented.
48+ """
3549 @ callback message ( t ) :: String . t ( )
3650
3751 @ doc """
Original file line number Diff line number Diff line change @@ -802,7 +802,7 @@ defmodule IEx.HelpersTest do
802802
803803 assert capture_io ( fn -> b ( NoMix . run ( ) ) end ) == "Could not load module NoMix, got: nofile\n "
804804
805- assert capture_io ( fn -> b ( Exception . message ( ) / 1 ) end ) ==
805+ assert capture_io ( fn -> b ( Exception . message ( ) / 1 ) end ) =~
806806 "@callback message(t()) :: String.t()\n \n "
807807
808808 assert capture_io ( fn -> b ( :gen_server . handle_cast ( ) / 2 ) end ) =~
You can’t perform that action at this time.
0 commit comments