`after` isn't just for `try`

defmodule RunAfter do
def without_even_trying do
raise "oops"
after
IO.puts("cleaning up!")
end
end
defmodule RunAfter do
def without_even_trying do
raise "oops"
after
IO.puts("cleaning up!")
end
end
See: https://hexdocs.pm/elixir/try-catch-and-rescue.html#after Real life example: https://github.com/ash-project/ash_postgres/blob/main/lib/migration_compile_cache.ex#L28-L40
GitHub
ash_postgres/lib/migration_compile_cache.ex at main · ash-project/...
The PostgreSQL data layer for Ash Framework. Contribute to ash-project/ash_postgres development by creating an account on GitHub.
3 Replies
ZachDaniel
ZachDaniel•5mo ago
Technically it is just for try def just has an implicit try
frankdugan3
frankdugan3OP•5mo ago
Technically, but not syntactically. 😛
Towry
Towry•4mo ago
after is for def too 🤓

Did you find this page helpful?