Skip to content

Instantly share code, notes, and snippets.

@falood
Last active March 11, 2017 16:45
Show Gist options
  • Select an option

  • Save falood/059ee5d7bff0fa812c557a2ce953c17c to your computer and use it in GitHub Desktop.

Select an option

Save falood/059ee5d7bff0fa812c557a2ce953c17c to your computer and use it in GitHub Desktop.

Revisions

  1. falood revised this gist Mar 11, 2017. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion Exception Step 1.md
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,10 @@ def func do
    raise "xxx"
    end

    rescue_from MatchError do
    IO.puts "error"
    end

    rescue_from Exception, as: e do
    IO.inspect e
    end
    @@ -16,7 +20,9 @@ def call do
    try do
    func()
    rescue
    Exception as e ->
    [MatchError] ->
    IO.puts "error"
    e in [Exception] ->
    IO.inspect e
    end
    end
  2. falood created this gist Mar 11, 2017.
    23 changes: 23 additions & 0 deletions Exception Step 1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    ```elixir

    def func do
    raise "xxx"
    end

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

    compile to

    ```elixir
    def call do
    try do
    func()
    rescue
    Exception as e ->
    IO.inspect e
    end
    end
    ```