Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Custom preprocessor exception message not shown in the page

prabudossh
Level 2
Level 2

Hi, 

We have written a custom preprocessor that gets invoked on page publish to identify if a particular component is present on the page and invoke a workflow for approval before page activation. This all works fine but the custom 'ReplicationException' is not showing up in the page. It shows up in the sites/siteadmin section when i click on "quick publish" button, but the exception is not showing up in the actual page when i click on "Publish Page". In the actual page, it only says "ERROR: Failed to publish the selected page(s)"

 

I am on AEM 6.4.6.0, any idea why this behavior?

1 Accepted Solution
Dipti_Chauhan
Correct answer by
Community Advisor
Community Advisor

Hi,

When you throw error message from processor e.g

 

throw new ReplicationException("your custom message");  This message only gets priority when you publish page from siteadmin.

 

If you want to show different error message when you publish from page then you need to overlay : http://localhost:4502/libs/cq/gui/components/authoring/editors/clientlibs/core.js    <Check quick publish option>.

 

Thanks

Dipti

 

 

View solution in original post

8 Replies
Jörg_Hoh
Employee
Employee

Is it documented that the exception message is displayed in the error message to the authors?

prabudossh
Level 2
Level 2

I am not sure if this is documented anywhere but i was looking into this file /libs/cq/gui/components/common/wcm/clientlibs/wcm/js/publish.js that has the necessary logic in fail/error condition. This is very similar change to quickpublish.js or managepublication.js that were being discussed in the other thread. I tried to overlay it but still no luck

Jörg_Hoh
Employee
Employee
Does the servlet then return the proper message at all, so it will be picked up by the JS?
prabudossh
Level 2
Level 2

the logic is working in sites/siteadmin area so wondering why it wouldn't work inside the page, I am posting the logic here anyway

 

@Override

public void preprocess(ReplicationAction action, ReplicationOptions options) throws ReplicationException {

try {

   ....

   if(needReview) {

      startWorkflow(...)

     throw new ReplicationException("The page contains xyz component and it has not been reviewed");

   }

}

catch () {

}

}

aalfarocr
Level 2
Level 2

Hi @prabudossh at the end did you solve the issue ?

 

I'm having the same issue, local env works displaying the custom message :

 

String errorMsg = String.format("Referenced assets : %1$s by page : %2$s are not tagged with the required tags.", assetWithInvalidTags.toString(), replicatedPath);

throw new ReplicationException(errorMsg);

 

expected.png

 

But in other environments just get a generic error msg :

 

current.png

 

Not sure what's the issue since it is the same code and the same AEM versions, but the custom error message is not working on some environments...

 

 

Dipti_Chauhan
Correct answer by
Community Advisor
Community Advisor

Hi,

When you throw error message from processor e.g

 

throw new ReplicationException("your custom message");  This message only gets priority when you publish page from siteadmin.

 

If you want to show different error message when you publish from page then you need to overlay : http://localhost:4502/libs/cq/gui/components/authoring/editors/clientlibs/core.js    <Check quick publish option>.

 

Thanks

Dipti

 

 

View solution in original post

prabudossh
Level 2
Level 2

You mean to say this one /libs/cq/gui/components/authoring/editors/clientlibs/core/js/actions/publish.js?

 

Will check it out, thanks!

Dipti_Chauhan
Community Advisor
Community Advisor
yes.. you need to overlay /libs/cq/gui/components/authoring/editors/clientlibs/core/js/actions/publish.js