Debug a script
The Script Editor provides a debugger to debug server scripts to troubleshoot code, for example, to inspect the value of variables, in real time.
Procedure
-
Set one or more breakpoints as required by selecting a line of code in the gutter on the left of the script editing pane to pause the debugger to inspect code.
Result: A red circle appears to designate the breakpoint at the line of code at which the debugger is set to pause.
-
Select the Debug icon.
Result: The debugger runs and pauses at the first set breakpoint. The Scope pane opens, and displays blocks of statements (
block
), functions with corresponding enclosed references (closures
), local variables (local
), and global variables (global
) for inspection within the selected scope associated with the function. The script output pane displays the execution of the script process and indicates the attachment of the debugger in the process. -
In the script editing pane, to move from the highlighted line of code to the next line of code, select the Step Over icon (or the shortcut key F10).
-
To move to method calls and variables that correspond to the highlighted line of code, select the Step Into icon (or the shortcut key F11).
-
To leave the current scope of the highlighted line of code and move to the last return statement from where the function was called from, select the Step Out icon (or the shortcut keys Shift + F11).
-
To resume debugging of the script until the next set breakpoint, select the Resume icon (or the shortcut key F8).
-
In the Evaluate Expression pane, to evaluate arbitrary expressions corresponding to the scope of the debugger, enter an expression to be considered when running the debugger to the set breakpoint.
Results
-
You have run the debugger for a script and can inspect your code according to the relevant use case.