To return error messages to the client, the method that works with all operations is to throw a VirtualViewerAPIException.

For example:

if (currentSecLevel.equals("0"))
{throw new VirtualViewerAPIException("Security violation detected");