custom exception in thingworx
I have created a ConnectedThingClient in java. I am using invokeService() method to call services of a particular thing at Thingworx server.
Can I send a custom exception from Thingworx which could be caught at java client end?
e.g.
throw{
"msg": <message>,
"module": <module_name>,
"projectVersion": <version>, ...
}
Requirement is this custom exception should be caught up at java client end, and I should be able to invoke methods as e.getMsg() or e.getModule() or e.getProjectVersion() considering e is the Exception object in catch.
But Thingworx raises error in script.
The workaround I am opting is-
I am creating the exception JSON with mentioned fields, converting this exception to a string and then throwing the string.
This way java client end calls e.getMessage() and then extracts the actual exception data from it.
So, I would like to know how can a custom exception be sent from Thingworx? And if not, is my workaround good or there can be a better solution to tackle this problem?

