Skip to content

Commit 99a0176

Browse files
Preserve interruptible callback control flow
1 parent f4c8a9f commit 99a0176

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

docs/capabilities/CAP-001-event-dispatch-parity/design.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Since Bot API 1.0.2, new-turn events dispatch at the end of `execute()`, which i
3636

3737
## Handler exceptions
3838

39-
The Bot API's event publisher catches subscriber exceptions so one callback cannot prevent other subscribers from receiving the event. That is compatible with classic's continued battle processing, but it hides the failure from the process logs that form conformance evidence. `BotPeer` therefore reports throwables at the legacy callback boundary and then returns to the Bot API queue; `IDR-006` records this narrow exception-reporting rule.
39+
The Bot API's event publisher catches subscriber runtime exceptions so one callback cannot prevent other subscribers from receiving the event. That is compatible with classic's continued battle processing, but it hides the failure from the process logs that form conformance evidence. `BotPeer` therefore reports runtime exceptions at the legacy callback boundary and then returns to the Bot API queue; control-flow errors used by the Bot API for interruptible handlers pass through unchanged. `IDR-006` records this narrow exception-reporting rule.
4040

4141
## The guard
4242

docs/decisions/IDR-006-report-legacy-handler-exceptions-at-the-bridge-boundary.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ title: Report legacy handler exceptions at the bridge callback boundary
1212

1313
## Decision
1414

15-
`BotPeer` invokes every legacy robot event callback inside a bridge-owned boundary. If the callback throws, the boundary prints the throwable to the bot process's standard error and returns so the surrounding event queue can continue dispatching.
15+
`BotPeer` invokes every legacy robot event callback inside a bridge-owned boundary. If the callback throws a runtime exception, the boundary prints it to the bot process's standard error and returns so the surrounding event queue can continue dispatching. Errors used by the Bot API for control flow, such as interrupting an event handler, are not caught.
1616

1717
## Context
1818

1919
The matched Tank Royale Bot API catches subscriber exceptions during event publication and otherwise provides no observable error to the conformance harness. Classic Robocode reports a `NullPointerException` thrown from `onStatus` while continuing the battle, so delegating event ordering to the Bot API is not enough to preserve the classic observable contract.
2020

2121
## Why this way
2222

23-
The boundary is the narrowest place that sees the legacy callback before the Bot API swallows its exception. Reporting there preserves the Bot API's priority and queue implementation, keeps the robot lifecycle unchanged, and gives the harness the same error signature that classic exposes. Replacing the upstream dispatcher or stopping the bot would alter unrelated event and lifecycle behavior.
23+
The boundary is the narrowest place that sees the legacy callback before the Bot API swallows its runtime exception. Reporting there preserves the Bot API's priority and queue implementation, keeps the robot lifecycle unchanged, and gives the harness the same error signature that classic exposes. Leaving control-flow errors untouched preserves interruptible-handler semantics. Replacing the upstream dispatcher or stopping the bot would alter unrelated event and lifecycle behavior.
2424

2525
## Consequences
2626

robocode-api/src/main/java/dev/robocode/tankroyale/bridge/BotPeer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ private void dispatchCustomEvent(BotEvent botEvent) {
454454
private void dispatchRobotCallback(Runnable callback) {
455455
try {
456456
callback.run();
457-
} catch (Throwable throwable) {
458-
throwable.printStackTrace();
457+
} catch (RuntimeException exception) {
458+
exception.printStackTrace();
459459
}
460460
}
461461

0 commit comments

Comments
 (0)