Now, we would like to be able to return a custom message in the exception. For example, instead of having “Failed to invoke operation: Test.UpdateDocMetadata operation”, we would like to have a custom message. Is this posible?

Invite people to answer

I can think about several possibilities, depending on what you have done. If I only look at the example you gave, you can:

set your custom message in the ExceptionTest class;

Create a complete custom Exception where you set up your custom message and you don't necessarily have to extend RestOperationException (but you may have to extend class org.nuxeo.ecm.automation.OperationException)

In the HttpStatusOperationTest class (with ExceptionTest), set your custom message when constructing the ExceptionTest or with (ExceptionTest.)setMessage before throwing the Exception

In the HttpStatusOperationTest class (when success in Automation Operation), root is a DocumentModel, which has metadata. From your very example, it has a metadata named “message”, so you should be able to update it with setProperty or setPropertyValue before returning root.