Hi
You could catch the errors/exceptions in your code and put the error message in an additional field of the result object.
Or you let extdirectspring handle the exceptions.
When an @ExtDirectMethod method throws an exception extdirectspring catches and wraps it into a response that looks like this:
[{"type":"exception","message":"Server Error","tid":2,"action":"myServerMethod","method":"doSomething"}]
The client receives this informations as the second parameter of the callback.
myServerMethod.doSomething(param1, param2, function(result, e) {
if (e.status) {
//everything ok
} else {
//something wrong
}
});
- status - true if the call was successful, false if something went wrong.
- result - contains the same data as the first parameter
- type - is 'rpc' or 'exception' when an error occurred
- action - the name of the bean. In this example 'myServerMethod'
- method - the name of the method ('doSomething')
- tid - a transaction number
- getTransaction() - retrieves the transaction used in this server call. This object contains some more information about the call. e.g. transaction.args contains the arguments the method was originally called with.