Skip to content

Instantly share code, notes, and snippets.

@falood
Last active March 11, 2017 16:45
Show Gist options
  • Save falood/059ee5d7bff0fa812c557a2ce953c17c to your computer and use it in GitHub Desktop.
Save falood/059ee5d7bff0fa812c557a2ce953c17c to your computer and use it in GitHub Desktop.
Macro in maru step by step: Exception
def func do
  raise "xxx"
end

rescue_from MatchError do
  IO.puts "error"
end

rescue_from Exception, as: e do
  IO.inspect e
end

compile to

def call do
  try do
    func()
  rescue
    [MatchError] ->
      IO.puts "error"
    e in [Exception] ->
      IO.inspect e
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment