cancel
Showing results for 
Search instead for 
Did you mean: 

Error custom messages throwing Exception

davidm
Confirmed Champ
Confirmed Champ

Hi,

i would like to throw some custom error in my Behaviour class when happens specific event over the node. Actually i use AlfrescoRuntimeExceptions with my message:


if(<event>) throw new AlfrescoRuntimeException("Custom Msg");

but Alfresco ignore this custom msg and build other to render it on the popup. Anyone knows how to build an custom error msg?

image

Thx in advance.

1 ACCEPTED ANSWER

afaust
Legendary Innovator
Legendary Innovator

While the linked thread is relevant for any instances where custom failure messages have been configured in Share actions, it does not apply to errors thrown from Repository-tier behaviours. But I believe we have had multiple such threads on behaviours as well - the root issue here is the way Alfresco treats behaviours with notification frequency of TRANSACTION_COMMIT - those will always be handled by a transaction listener, which wraps any exceptions in an extremely generic message.

One such thread is https://hub.alfresco.com/t5/alfresco-content-services-forum/how-to-get-the-proper-exception-message-... - though this relates to a CMIS client, the core problem is the same. If you want this error message to show in Share, you need to use either EVERY_EVENT or FIRST_EVENT as notification frequency, or hope that Alfresco decides to suddenly change/fix this handling which has remained stable for ~10 years.

View answer in original post

4 REPLIES 4

EddieMay
World-Class Innovator
World-Class Innovator

Hi @davidm,

This post might be helpful > https://hub.alfresco.com/t5/alfresco-content-services-forum/get-exception-on-action-java-class-and-o...

Kind regards, 

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!

afaust
Legendary Innovator
Legendary Innovator

While the linked thread is relevant for any instances where custom failure messages have been configured in Share actions, it does not apply to errors thrown from Repository-tier behaviours. But I believe we have had multiple such threads on behaviours as well - the root issue here is the way Alfresco treats behaviours with notification frequency of TRANSACTION_COMMIT - those will always be handled by a transaction listener, which wraps any exceptions in an extremely generic message.

One such thread is https://hub.alfresco.com/t5/alfresco-content-services-forum/how-to-get-the-proper-exception-message-... - though this relates to a CMIS client, the core problem is the same. If you want this error message to show in Share, you need to use either EVERY_EVENT or FIRST_EVENT as notification frequency, or hope that Alfresco decides to suddenly change/fix this handling which has remained stable for ~10 years.

davidm
Confirmed Champ
Confirmed Champ

Thanks Axel, with EVERY_EVENT stage works well and share shows my custom msg. It would be nice if @alfresco implemented this option at TRANSACTION_COMMIT too Smiley Wink.

EddieMay
World-Class Innovator
World-Class Innovator

Hi @davidm,

Thanks for following up - this helps others in the community to know this works. Thanks also for you suggestion.

Kind regards, 

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!