From MiniScript Wiki
Jump to navigation Jump to search

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.


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
[ line 276,
    (current program) line 152, line 165, 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
  2. The next line shows where that final call into was made, i.e., line 152 of the currently loaded program.
  3. That was called from 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