Skip to content

Instantly share code, notes, and snippets.

@zacky1972
Created September 9, 2022 21:53
Show Gist options
  • Save zacky1972/a94728a10d73e65c28c0f7cfedbe833c to your computer and use it in GitHub Desktop.
Save zacky1972/a94728a10d73e65c28c0f7cfedbe833c to your computer and use it in GitHub Desktop.
Custom exception in Elixir
  1. mix new example_error
  2. cd example_error
  3. Edit lib/example_error.ex
  4. iex -S mix
  5. Enter the following command:
try do
  raise ExampleError
rescue
  e in ExampleError -> e
end
defmodule ExampleError do
defexception message: "an example error has occurred"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment