Service Function Error Result

I have a service function in my XData server.

function search( Filter: string) : TJSONObject;

At Client side:

xClient: TXDataClient;
myFunc: IMyFunc;

  json: TJSONObject;
  json := 'filter');

How can I get the errormessage?
I have an error in serverfunction. The result is NIL; json is nil.

Is there any way to get the error?

Json is nil is not an error. It's simply a valid result. You should check for that at client-side.

If there is any exception raised in the server, such exception is propagated to the client normally (the exception is raised in the client).

Yes, I mean that due to an exception the result is nil.
And I want to check for this.

When does the exception come?
After the line:  "json := 'filter');" I did not get an exception.
I will make an extended check tomorrow.

The result will not be nil due to an exception, unless you caught the exception server-side and explicitly returned nil. Then it's up to you.

If server-side, inside your search function, any exception is raised, then calling such function in the client will also raise an exception.