Debugger - Break on exception

Answered

Hi,

My only real use case for the debugger is to have it break on exceptions, so when an exception is raised it stops and shows me the location and exception so I wondered whether this is possible?

I've looked at the breakpoint functionality for exceptions but I'm not sure how useful that is when compared to breaking on exceptions.

Thanks,

Colin

0
7 comments

Hello Colin,

Yes, exception breakpoints seems to be exactly what you are looking for. Learn more about them here: http://www.jetbrains.com/ruby/webhelp/types-of-breakpoints-2.html

Regards,
Oleg

0

I must be missing something regarding these exception breakpoints, I'll give you an example just to check if I'm misunderstanding your use (as they're not really documented in the linked page and my searches brought up no useful references).

Lets say I have this code:

String.class_eval { define_method(screaming_caps) { upcase } }
p "dsdasda".screaming_caps
If I try to run I get told clearly whats wrong "undefined local variable or method `screaming_caps' for String:Class (NameError)". However I try to debug anyway, I've setup an exception breakpoint for NameError but nothing happens, the debug window shows but nothing appears so I have no idea whats going on. In fact in this situation the debugger is useful, I don't get any output telling me what went wrong.

Note this is against 3.2 beta.

0

Is there an update to this thread that applies to IntelliJ 2024? The link given in the answer from 13 years ago is no longer valid and this post came up in the top 3 on Google search.

0

Jason Zwolak could you please specify your RubyMine and Ruby versions and also the problem you're facing?

0

Hi Olga, my problem is that the link given in the first answer is bad. It's this link: http://www.jetbrains.com/ruby/webhelp/types-of-breakpoints-2.html

I'm looking for similar documentation that describes the solution to setting "break on exception". I'm actually using IDEA Ultimate 2024.1.4, but I have found that documentation for any JetBrains product often works with other products.

0

Hi Jason, 

Here is the correct link where you can find more information about working with exceptions:
https://www.jetbrains.com/help/ruby/using-breakpoints.html#exception-breakpoints

 

1

Thank you! Perfect!

0

Please sign in to leave a comment.