cafe-latte
cafe-latte copied to clipboard
Avoid creating stack trace for ControlFlowException?
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;
}
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?
Is this issue closeable after merging #9?
yes you can close it