We have a naming convention in Elixir where functions with ! suffixed at the end of its name (e.g. run!) will raise an exception if the function encounters an error.
Enum.fetch! is one example. It has a sibling Enum.fetch function which does not raise exception. Both functions finds the element at the given index. The difference is Enum.fetch! raises OutOfBoundsError if the given position is outside the range of the collection.
Here’s a nice macro you can use to generate bang! versions of your existing non-raising functions.
Let’s see a full example.
In the above code, we have two functions run and run!. Notice that we using our bang macro to generate the bang version of run.