Elixir Tricks & Tips for develop & debugging

Intro

I will continue add tips & tricks for develop/debugging with Elixir in this topic for sharing my experiences about Elixir.

Add .iex.exs file for easy develop & debug

Add .iex.exs file to root folder of Elixir app th…


This content originally appeared on DEV Community and was authored by Mạnh Vũ

Intro

I will continue add tips & tricks for develop/debugging with Elixir in this topic for sharing my experiences about Elixir.

Add .iex.exs file for easy develop & debug

Add .iex.exs file to root folder of Elixir app then:

  1. Add alias to avoid type much

example add

alias MyApp.Background.Worker, as: W

to your .iex.exs and run with iex -S mix or iex -S mix phx.server then in Elixir shell you can type like:

W.run()
  1. Add function/script support for debugging. You can add a script or function needed for debugging then run in Elixir shell.

rescue in body function

when define a function you can directly use rescue in body without try keyword.

Example:

  def server_info(endpoint, scheme) do
    address =
      endpoint
      |> make_ref(scheme)
      |> :ranch.get_addr()

    {:ok, address}
  rescue
    e -> {:error, Exception.message(e)}
  end

(code from :swarm library)


This content originally appeared on DEV Community and was authored by Mạnh Vũ


Print Share Comment Cite Upload Translate Updates
APA

Mạnh Vũ | Sciencx (2024-06-20T02:11:31+00:00) Elixir Tricks & Tips for develop & debugging. Retrieved from https://www.scien.cx/2024/06/20/elixir-tricks-tips-for-develop-debugging/

MLA
" » Elixir Tricks & Tips for develop & debugging." Mạnh Vũ | Sciencx - Thursday June 20, 2024, https://www.scien.cx/2024/06/20/elixir-tricks-tips-for-develop-debugging/
HARVARD
Mạnh Vũ | Sciencx Thursday June 20, 2024 » Elixir Tricks & Tips for develop & debugging., viewed ,<https://www.scien.cx/2024/06/20/elixir-tricks-tips-for-develop-debugging/>
VANCOUVER
Mạnh Vũ | Sciencx - » Elixir Tricks & Tips for develop & debugging. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/06/20/elixir-tricks-tips-for-develop-debugging/
CHICAGO
" » Elixir Tricks & Tips for develop & debugging." Mạnh Vũ | Sciencx - Accessed . https://www.scien.cx/2024/06/20/elixir-tricks-tips-for-develop-debugging/
IEEE
" » Elixir Tricks & Tips for develop & debugging." Mạnh Vũ | Sciencx [Online]. Available: https://www.scien.cx/2024/06/20/elixir-tricks-tips-for-develop-debugging/. [Accessed: ]
rf:citation
» Elixir Tricks & Tips for develop & debugging | Mạnh Vũ | Sciencx | https://www.scien.cx/2024/06/20/elixir-tricks-tips-for-develop-debugging/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.