cafe-latte icon indicating copy to clipboard operation
cafe-latte copied to clipboard

Avoid creating stack trace for ControlFlowException?

Open axkr opened this issue 3 years ago • 1 comments

As I understand your flow control exceptions, the stack trace is not needed for debugging or similar purposes:

  • https://github.com/phoe/cafe-latte/blob/7b2cd83ee1d81eb0712fd0a9f3ad36c6cdbb1c56/src/main/java/systems/raptor/cafe_latte/control_flow/ControlFlowException.java#L3

See: https://www.baeldung.com/java-exceptions-performance

so you can override fillInStackTrace in Throwable (or make it configurable with a global flag?)

 @Override
  public synchronized Throwable fillInStackTrace() { 
      return this;
  }

axkr avatar Sep 26 '21 13:09 axkr

Almost. ControlFlowException is meant to be thrown from invalid code, such as blocks/tagbodies that are no longer in scope or flings that are not in a dynamic context of a grasp; see e.g.

https://github.com/phoe/cafe-latte/blob/7b2cd83ee1d81eb0712fd0a9f3ad36c6cdbb1c56/src/main/java/systems/raptor/cafe_latte/control_flow/block/Block.java#L48

For those, we absolutely should have stack traces, since filling those in is going to be important in debugging.

But, you were close. TransferOfControl does not need stacktraces indeed, since these are only thrown within correct code. Feel like making a PR that removes stacktraces from these?

phoe avatar Sep 26 '21 22:09 phoe

Is this issue closeable after merging #9?

phoe avatar Oct 03 '22 06:10 phoe

yes you can close it

axkr avatar Oct 03 '22 08:10 axkr