Stepping through code with the debugger
The debugger lets you stop time inside a running program. Instead of guessing what a value is, you look at it.
Set a breakpoint
Click in the margin beside a line of code to place a breakpoint. Run the project and trigger the page. Execution stops at that line and the editor shows the current values of every variable in scope.
Move through the code
- Step over. Run the current line and stop at the next one.
- Step into. Go inside the method that is being called.
- Continue. Run on until the next breakpoint.
Watch the values. Hover over a variable to see what it holds right now. The gap between what you expected and what is there is usually the whole bug.
Debugging works best on code that builds cleanly and is readable. If a page throws an error in production rather than on your machine, the Error Handler project records the details for you.