The community commons has a java action ThrowWebserviceException. May be you could use this.
Regards,
Ronald
There is a built in java action for that throwRestServiceException
.
See https://github.com/mendix/restservices#publish
It can be used safely inside webservices operations as well, so that you can apply the same error handling in both implementations