Lalant commented on code in PR #7482:
URL: https://github.com/apache/ignite-3/pull/7482#discussion_r2797235408
##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/TxStateMeta.java:
##########
@@ -191,6 +239,56 @@ public TxState txState() {
return txLabel;
}
+ public @Nullable List<TxStateMetaExceptionInfo> exceptionInfos() {
+ return exceptionInfos;
+ }
+
+ /**
+ * Records exceptional information by mutating tx state or by creating a
new one. This method should be called after tx is finished.
+ *
+ * @param old previous TxStateMeta.
+ * @param throwable to record
+ */
+ public static TxStateMeta recordExceptionInfo(@Nullable TxStateMeta old,
Throwable throwable) {
+ TxStateMetaExceptionInfo exceptionInfo = fromThrowable(throwable);
+ return old == null
+ ? builder(old, ABORTED).exceptionInfo(exceptionInfo).build()
+ : old.mutate().exceptionInfo(exceptionInfo).build();
+ }
+
+ /**
+ * Aggregates exception infos into a single throwable, using the last
exception as the primary one and attaching previous exceptions as
+ * suppressed.
+ *
+ * @param exceptionInfos Exception infos list.
+ * @return Aggregated throwable or {@code null} if nothing usable is
present.
+ */
+ public static @Nullable Throwable aggregateExceptionInfos(@Nullable
List<TxStateMetaExceptionInfo> exceptionInfos) {
+ if (exceptionInfos == null || exceptionInfos.isEmpty()) {
+ return null;
+ }
+
+ Throwable primary = exceptionInfos.get(exceptionInfos.size() -
1).throwable();
Review Comment:
I've seen a scenario where the last one was primary, but actually it doesn't
matter, there are scenarios, when it is the 1st. So lets keep it simple.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]