-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
raising inside dbg is not handled #14005
Comments
It's an interesting idea, but I think it's a trade-off though: if intermediate steps are printing to stdout too, the pipeline might become unreadable: iex(1)> :world |> then(&IO.puts("hello #{&1}!")) |> Atom.to_string() |> dbg()
hello world!
[iex:1: (file)]
:world #=> :world
|> then(&IO.puts("hello #{&1}!")) #=> :ok
|> Atom.to_string() #=> "ok" would become [iex:1: (file)]
:world #=> :world
hello world!
|> then(&IO.puts("hello #{&1}!")) #=> :ok
|> Atom.to_string() #=> "ok" We could also imagine wrapping in a try + reraise, but I'm not sure it's a good approach either. Adding more intermediate |
What motivated me to create this issue was dbg on a simple function call:
The function raised and I had to add inspects before it. |
I would avoid try-catch. But I think the intermediate printing would be nice! |
Something like this example? This will allow calling dbg on the condition. defp dbg_ast_to_debuggable({:if, meta, [condition_ast, clauses]} = ast, env, options) do
condition_result_var = unique_var(:condition_result, __MODULE__)
result_var = unique_var(:result, __MODULE__)
quote do
Macro.write_underline("If condition", unquote(options))
unquote(condition_result_var) = unquote(condition_ast)
Macro.write_ast_value(
unquote(escape(condition_ast)),
unquote(condition_result_var),
unquote(options)
)
Macro.write_underline("If expression", unquote(options))
unquote(result_var) = unquote({:if, meta, [condition_result_var, clauses]})
Macro.write_ast_value(
unquote(escape(ast)),
unquote(result_var),
unquote(options)
)
unquote(result_var)
end
end |
That would work for |
@dkuku would you like to send a PR here? |
@josevalim I'm thinking about it, but I believe it requires changes to all current debug implementations. |
Sorry, we may be speaking about two different things then. It thought this would ultimately simply attach more information to |
This is not the complete PR. I was experimenting with moving the dbg to a new module and exposing the private functions from macro as public. |
@dkuku I got it. We can do it one by one, we don't need to change them all at once, especially because I don't think we can necessarily change all of them. :) |
I have the pr for |
|
Elixir and Erlang/OTP versions
any recent
Operating system
any
Current behavior
Currently when there is an exception we don't get any output in dbg. When debugging pipes I need to add inspects in the pipeline idealy with labels to see where it failed.
returns
Expected behavior
Rendering partial result would be ideal, this way we would know what was the input to the failing function.
Currently the dbg is generated in 2 steps
It may be possible if the dbg result would be generated where the code is executed and in case of exceptions we could just display what was generated up to that point.
The text was updated successfully, but these errors were encountered: