quarkiverse / quarkus-renarde

Server-side Web Framework with Qute templating, magic/easier controllers, auth, reverse-routing
Apache License 2.0
78 stars 22 forks source link

Handle exception but force a rollback #199

Open gbourant opened 8 months ago

gbourant commented 8 months ago

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();
}
pramoth commented 2 months ago

I think it should be better to associate Exception with 'error template' and automatically handle by renarde like this

@ErrorTemplate(CustomException.class)
 public static native TemplateInstance authError(CustomException e);

If we manually handle exception that means we must manually handle transaction too.