Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle exception but force a rollback #199

Open
gbourant opened this issue Feb 21, 2024 · 1 comment
Open

Handle exception but force a rollback #199

gbourant opened this issue Feb 21, 2024 · 1 comment

Comments

@gbourant
Copy link
Contributor

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
Copy link
Contributor

pramoth commented Sep 4, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants