I have an API that uses Zend_Json_Server and defines a class that handles the requests. However, how can I return an error, so that I can set the message AND the error code? When I throw a new exception, I can only set the message. The exception code is not used.
I found the solution:
The error code has to be somewhere between -32099 and -32000.
So you can throw an Exception and pass one of those valid error codes.
Why don't you call the fault method on Zend_Json_Server?