How to update saga compensation passed object value

Hey,

I am using spring boot alongside with Temporal.
In my work flow In case that an exception was thrown inside the workflow I have to reflect the reason in the compensation logic.
For example, if during my work flow a db activity threw an exception I need to pass into the compensation a message reflecting this (something like “DB Operation failed”), or in case other activity failed I have to reflect that reason.
I tried to create a wrapper object and pass it into the compensation and during the catch phase to set its internal errorMessage string value, I tried to pass direct string but nothing worked.
Please advise.

example code:

 @Override
    public void execute() {
        var saga = new Saga.Options.Builder().setContinueWithError(true).build();
        var errorMessageContainer = new ErrorMessageContainer();
        try {
            saga.addCompensation(clientNotifaction::notifyFailure, errorMessageContainer);
        } catch (Exception e) {
            saga.compensate();
            errorMessageContainer.setErrorMessage("custom message");
            throw e;
        } 
    }

I would first set the error message and then call saga.compensate.