Skip to main content

APIzation: Replication Package

[Q#49003222][A#49014692] How to get stack trace in Processing debugger

https://stackoverflow.com/q/49003222

Is there any way to show a stack trace in the Processing 3 debugger (Java mode)? Not by catching an exception. I know about e.printStackTrace(). I want to print a stack trace in the debugger at a custom breakpoint. Thanks!

Answer

https://stackoverflow.com/a/49014692

I don't know of a way to view the stack in Processing's debugger. The Processing debugger is designed to be pretty simple. If you really need this functionality, consider switching to a more advanced IDE like Eclipse or Intellij. Shameless self-promotion: here is a tutorial I wrote on using Processing in Java. But if you just watch something quick and simple, you can also manually print out the stack trace by creating a new Exception: This will print out a stack trace to the console without actually throwing an error. Put this line right before your break point to see the breakpoint's stack trace.

APIzation

new Exception().printStackTrace();
package com.stackoverflow.api;

public class Human49014692 {

  public static void printStacktrace() {
    new Exception().printStackTrace();
  }
}

package com.stackoverflow.api;

/**
 * How to get stack trace in Processing debugger
 *
 * @author APIzator
 * @see <a href="https://stackoverflow.com/a/49014692">https://stackoverflow.com/a/49014692</a>
 */
public class APIzator49014692 {

  public static void getTrace() throws Exception {
    new Exception().printStackTrace();
  }
}