Skip to content

Commit

Permalink
Improve the error return
Browse files Browse the repository at this point in the history
  • Loading branch information
norbajunior committed Mar 29, 2021
1 parent b49b14b commit cd1dfde
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def House.Door do
end
```

By defining this rules we get the function `Door.transit/2` to transit between states. This function returns either `{:ok, struct_with_new_state}` or `{:error, :not_allowed}`. Lets see this in practice:
By defining this rules we get the function `Door.transit/2` to transit between states. This function returns either `{:ok, struct_with_new_state}` or `{:error, message}`. Lets see this in practice:

By default our `Door` is `locked`

Expand All @@ -59,7 +59,7 @@ If we try to make a transition that not follow the rules, we get an error:

```elixir
iex> House.Door.transit(door, event: "close")
{:error, :not_allowed}
{:error, "can't transit from unlocked to closed"}
```

### Setting different field name that holds the state
Expand Down

0 comments on commit cd1dfde

Please sign in to comment.