Difference between revisions of "StackTrace"
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") |
|||
(One intermediate revision by the same user not shown) | |||
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. |
− | + | This may be used in code, at runtime, but more typically it is used on the command line after a program aborts due to an error. | |
+ | |||
+ | == 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]] |
Latest revision as of 03:34, 4 January 2023
In Mini Micro and Farmtronics, the stackTrace
method returns a list of program locations that represent the call stack.
This may be used in code, at runtime, but more typically it is used on the command line after a program aborts due to an error.
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:
- 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