vertx-sql-client icon indicating copy to clipboard operation
vertx-sql-client copied to clipboard

Show why a rollback occurred in exceptions

Open doctorpangloss opened this issue 3 years ago • 0 comments

Describe the feature

It would be nice to see what exception caused the rollback instead of passing Future.failedFuture("Rollback exception") here, which also gives us a NoStackTraceException.

  private <T> Handler<AsyncResult<T>> wrap(Handler<AsyncResult<T>> handler) {
    return ar -> {
      synchronized (TransactionImpl.this) {
        status = ST_PENDING;
        if (ar.failed()) {
          // We won't recover from this so rollback
          ScheduledCommand<?> c;
          while ((c = pending.poll()) != null) {
            c.handler.handle(Future.failedFuture("Rollback exception"));
          }
          schedule__(doQuery(ROLLBACK, context.promise(ar2 -> {
            handler.handle(ar);
          })));
        } else {
          handler.handle(ar);
          checkPending();
        }
      }
    };
  }

Use cases

This helps me understand which of many SQL queries may be broken.

Contribution

I could do the PR if it would get merged. It's more of a matter of what you want.

doctorpangloss avatar Nov 25 '20 22:11 doctorpangloss