How can I configure VS Code to break on any exception in a Rails application? (Using ruby-debug-ide and debase)

940 Views Asked by At

I've set up the ruby-debug-ide and debase gems in my Rails application so that I can use VS Code's built-in debugging tools.

During development, I would like any exception to trigger a breakpoint and start the debugger in VS Code. How can I set this up?

1

There are 1 best solutions below

0
On

I was unable to do this using debase and recommend using gem debug instead, along with extension "VSCode rdbg Ruby Debugger".

You'll get a "rescue any exception" breakpoint which works (though I wasn't able to get it to rescue only uncaught exceptions).

enter image description here

See https://github.com/ruby/vscode-rdbg and https://github.com/ruby/debug

This is the launch.json for my rails application

{
    "type": "rdbg",
    "name": "Debug Rails with rdbg",
    "rdbgPath": "bundle exec rdbg",
    "request": "launch",
    "cwd": "${workspaceFolder}",
    "command": "${workspaceFolder}/bin/rails",
    "script": "server",
    "args": [
        "-p",
        "8080"
    ]
}