Difference between revisions of "StackTrace"

From MiniScript Wiki
Jump to navigation Jump to search
(Created page with "In Mini Micro, the <c>stackTrace</c> method returns a list of program locations that represent the call stack. {{stub}} Category:Mini Micro")
 
Line 1: Line 1:
In [[Mini Micro]], the <c>stackTrace</c> method returns a list of program locations that represent the call stack.
+
In [[Mini Micro]] and [[Farmtronics]], the <c>stackTrace</c> method returns a list of program locations that represent the call stack.
  
{{stub}}
+
 
 +
== Example ==
 +
 
 +
In this hypothetical example, a program two [[import]] modules, <c>gui</c> and <c>events</c>, encounters a error in the <c>gui</c> module that causes the program to break out to the command line.  Entering '''<c>pprint stackTrace</c>''' at this point produces the following.
 +
 
 +
<pre>]pprint stackTrace
 +
[
 +
    gui.ms line 276,
 +
    (current program) line 152,
 +
    events.ms line 165,
 +
    events.ms line 203,
 +
    (current program) line 323
 +
]</pre>
 +
 
 +
This <c>stackTrace</c> result is interpreted as follows:
 +
 
 +
# The first line in the result is where the error occurred: line 276 of the file ''gui.ms''.
 +
# The next line shows where that final call into ''gui.ms'' was made, i.e., line 152 of the currently loaded program. 
 +
# That was called from ''events.ms'' line 165...
 +
# which in turn was called from line 203 of the same module.
 +
# Finally, that initial call into ''events'' was made from line 323 of the current program.
 +
 
 +
In this way, you can see not only where the error occurred, but how the code got there.
 +
 
 +
See also: [[Debugging Tips]]
  
 
[[Category:Mini Micro]]
 
[[Category:Mini Micro]]
 +
[[Category:Farmtronics]]

Revision as of 03:33, 4 January 2023

In Mini Micro and Farmtronics, the stackTrace method returns a list of program locations that represent the call stack.


Example

In this hypothetical example, a program two import modules, gui and events, encounters a error in the gui module that causes the program to break out to the command line. Entering pprint stackTrace at this point produces the following.

]pprint stackTrace
[
    gui.ms line 276,
    (current program) line 152,
    events.ms line 165,
    events.ms line 203,
    (current program) line 323
]

This stackTrace result is interpreted as follows:

  1. The first line in the result is where the error occurred: line 276 of the file gui.ms.
  2. The next line shows where that final call into gui.ms was made, i.e., line 152 of the currently loaded program.
  3. That was called from events.ms line 165...
  4. which in turn was called from line 203 of the same module.
  5. Finally, that initial call into events was made from line 323 of the current program.

In this way, you can see not only where the error occurred, but how the code got there.

See also: Debugging Tips