cancel
Showing results for 
Search instead for 
Did you mean: 

REST Custom ErrorCode and Message

sarkar92
Champ in-the-making
Champ in-the-making
In previous aciviti REST version if any exception occurred in process it will send only 500 ( internal server error ).
But in Activiti 5.13 REST version now we can get exact error code with message (e.g 401- unauthorized ).

My question is that can I add my custom error code and message ,so that I can get from REST response.
If possible ,then how can I add that??

thanks
biswajit
3 REPLIES 3

frederikherema1
Star Contributor
Star Contributor
See the ActivitiStatusService class (https://github.com/Activiti/Activiti/blob/8b3b750b9a2b88fbf888761ea6afe81c7012da9a/modules/activiti-...). You can set a custom implementation of that class in the RestApplication you're using (subclass the existing application and call setStatusService() when initializing).

You'll get an exception passed in when one occurs, and you'll be able to return a custom status and even a custom error-JSOn body (or other body).

sarkar92
Champ in-the-making
Champ in-the-making
I am not able to find the class "ActivitiStatusService " in this path " activiti-rest / src / main / java / org / activiti / rest / application  "

frederikherema1
Star Contributor
Star Contributor
I pointed you to the class that tests the behavior. See https://github.com/Activiti/Activiti/blob/8b3b750b9a2b88fbf888761ea6afe81c7012da9a/modules/activiti-... for the actual class… Github has an awesome search-feature, you know Smiley Wink