How to return/handle json exceptions in TaskComplete (REST)

I added handling of validation errors on process start using the withVariablesInReturn as answered in my other question. Custom Exception Handling

Description of my Issue:
I complete a task form (custom frontend) using rest, which is followed by a syncron service task to validate user input. Now there is a problem with the data and i can throw a exception. That exception reaches my frontend as html exception, which can not be parsed. I do want a method to return json / or any other structured data describing the errors to the frontend.

Idea 1:
The user task complete sadly does not offer the withVariablesInReturn option and camunda does not plan an adding it. -> Plans to add variable return on User Task Completion?

Idea 2:
Another method would be to offer us custom exceptions which can be returned as json from anywhere. But there are also no plans to add this: Limit number of concurrently running processes

Idea 3 (not good):
The only way i found that could work is to write a custom jax-rs app to wrap the engine-rest camunda api and adds a exception mapper. But i do don’t want to maintain a private jax-rs app just to add such a essential feature to the engine-rest.

Are there any other ways (best-practice by camunda / no custom app) i’m unaware of or is there a public project for the jax-rs wrapper?

How did you handle this in your applications?

Kind Regards,
Philipp Heuer

1 Like

That is exactly the same problem I got. My client also needs some extra information when completing a task and the validation of data fails.
Unfortunately he definitely doesn’t want me to customize the engine-rest, so I also would appreciate another way of custom exception handling.

Best regards,
Constantin

As a workaround, you could create another process with a script task that completes user tasks from another process. So your new process would process the user task complete using the Java API and return variable info using variables in return. Whatever logic you needed would be put into your script task.

Similar to what is discussed here https://github.com/DigitalState/Services/issues/42.