Skip to content

Commit 95fab64

Browse files
committed
Changed to defexception/1 inside a module in custom error example
1 parent 44cf969 commit 95fab64

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

getting_started/17.markdown

+4-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ iex> raise ArgumentError, message: "invalid argument foo"
3434
** (ArgumentError) invalid argument foo
3535
```
3636

37-
You can also define your own errors using the `defexception/2` macro. The most common case is to define an exception with a message field:
37+
You can also define your own errors by creating a module and use the `defexception/1` macro inside it. The most common case is to define an exception with a message field:
3838

3939
```iex
40-
iex> defexception MyError, message: "default message"
40+
iex> defmodule MyError do
41+
iex> defexception message: "default message"
42+
iex> end
4143
iex> raise MyError
4244
** (MyError) default message
4345
iex> raise MyError, message: "custom message"

0 commit comments

Comments
 (0)