Skip to content

Instantly share code, notes, and snippets.

View gamache's full-sized avatar
🤙

pete gamache gamache

🤙
View GitHub Profile
@gamache
gamache / safe_task.ex
Created March 24, 2016 19:25
SafeTask proof of concept: make a Task's raises, throws, and exits happen locally
defmodule SafeTask do
def async(func) do
safe_func = fn ->
try do
{:ok, func.()}
rescue
e -> {:error, e}
catch
:exit, x -> {:exit, x}
t -> {:throw, t}