Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug quickly in phoenix/elixir?

As I am learning Elixir/Phoenix, I happen to run into an issue like this often.

The problem is that this comes from a dependency, so normally I do this:

  • open deps/something/.../thefile.ex
  • add some debug code like IO.inspect to see what params are being passed
  • stop server, recompile with mix deps.recompile something
  • check the documentation to see what types are expected to that function
  • compare the types and trace down the problem to my code

This works but I'd like to improve my process, I know I can use Iex to start a repl, but I'd like to get much faster in terms of:

  • having a repl inside of the error page itself started automatically (like in better_errors gem for Rails)
  • having a way to see what arguments went into that method without me digging around (could be solved by the former point)
  • being able to see a method's documentation quickly

Also any other tips are greatly appreciated.

enter image description here

like image 485
hakunin Avatar asked May 20 '17 14:05

hakunin


1 Answers

Please open up an issue in Plug: https://github.com/elixir-lang/plug

You have some great suggestions, like accessing the docs and make the arguments explicit. I don't think we can provide a REPL at the place of error though.

EDIT 1: I went ahead and opened an issue here since I got excited about those improvements! :D

EDIT 2: I realize that I should probably have used a comment as this is not quite an answer (yet!)

like image 168
José Valim Avatar answered Oct 19 '22 00:10

José Valim