23 lines
687 B
Markdown
23 lines
687 B
Markdown
|
# Hints
|
||
|
|
||
|
## General
|
||
|
|
||
|
- Read about [errors][errors] in the Getting Started guide.
|
||
|
- Read about [`try`][docs-try] in the documentation.
|
||
|
|
||
|
## 1. Warn the team
|
||
|
|
||
|
- Allow the operation function to raise its error.
|
||
|
- To invoke a function in a variable, use the `.` operator.
|
||
|
|
||
|
## 2. Wrap the error
|
||
|
|
||
|
- Make use of try .. rescue to return the intended result.
|
||
|
|
||
|
## 3. Pass on the message
|
||
|
|
||
|
- Make use of try .. rescue to return the intended result.
|
||
|
- The rescue block allows you to pattern match on the error's Module name and also bind the error to a variable.
|
||
|
|
||
|
[errors]: https://hexdocs.pm/elixir/try-catch-and-rescue.html#errors
|
||
|
[docs-try]: https://hexdocs.pm/elixir/Kernel.SpecialForms.html#try/1
|