Search
 
SCRIPT & CODE EXAMPLE
 

ELIXIR

elixir after

defmodule SomeModule do
  @doc """
      iex> SomeModule.do_something()
      # Cleaning up...
      {:error, "%ArgumentError{message: "You provided a wrong argument"}"}
  """
  def do_something() do
    raise ArgumentError, "You provided a wrong argument"
  rescue
    error -> {:error, "#{inspect(error)}"}
  after
    clean_up()
  end

  @doc """
      iex> SomeModule.try_something()
      # Cleaning up...
      {:error, "%ArgumentError{message: "You provided a wrong argument"}"}
  """
  def try_something() do
    try do
      raise ArgumentError, "You provided a wrong argument"
    rescue
      error -> {:error, "#{inspect(error)}"}
    after
      clean_up()
    end
  end

  defp clean_up() do
    IO.puts("Cleaning up...")
  end
end
Comment

PREVIOUS NEXT
Code Example
Elixir :: elixir string to datetime 
Elixir :: elixir guard 
Elixir :: elixir hello world 
Elixir :: jason elixir 
Elixir :: elixir list map key string to atom 
Elixir :: phoenix enum filter 
Elixir :: elixir sleep 
Elixir :: elixir string show inner binary 
Scala :: scala hello world 
Scala :: scala empty list 
Scala :: dataframe column json parser spark scala 
Scala :: how to print message in scala 
Actionscript :: Application insights powershell 
Excel :: google sheets convert month to number 
Excel :: or function in excel 
Perl :: perl regex syntax 
Perl :: difference between @ and $ in perl 
Pascal :: pascal exception handling 
Powershell :: powershell display firewall rules name 
Gdscript :: godot check if in exported version 
Abap :: abap integer 
Assembly :: program in assembly language to find even numbers from 1 to 10 
Assembly :: cout boolalpha 
Assembly :: links in markdown 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: jquery remove required attribute 
Javascript :: react refresh page 
Javascript :: javascript void(0) href 
Javascript :: get tomorrows date using moment 
Javascript :: random number between 0 and 3 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =