quarkus-renarde icon indicating copy to clipboard operation
quarkus-renarde copied to clipboard

Handle exception but force a rollback

Open gbourant opened this issue 1 year ago • 1 comments

As discussed in issue 38839, if we use a try catch block and return a template then the transaction is not rollbacked. In order to force a rollback we need something like this

@Path("login")
public TemplateInstance loginPage(User user)
        try {
            authService.register(user);
        } catch (Exception e) {
            // transaction is not rollbacked
            return AdminTemplate.auth(e);
        }
        return AdminTemplate.auth();
}

gbourant avatar Feb 21 '24 04:02 gbourant