Skip to Content
Jan 24 at 05:42 PM

CAP JAVA: Throw ServiceException without database rollback

165 Views Last edit Jan 24 at 05:45 PM 3 rev


I have a custom event handler which updates some database tables. If there occurs any error I use the ServiceException class to pass the error to the user. But then all the database changes are rollbacked.

 throw new ServiceException(ErrorStatuses.FORBIDDEN, messages.error("CONSENT_CONTRACT_TO_MANY_ATTEMPS").getMessage());

Is there a way to keep the database changes and still pass the error to the user?

If I use the message class without the exception the statusCode is not set to 400 and the message ust occurs in the response header.

Best regards,