com.sentilla.host.client.admin
Class ServiceException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by com.sentilla.host.client.admin.ServiceException
All Implemented Interfaces:
Serializable

public class ServiceException
extends RuntimeException

Used to throw exceptions for service APIS. Typically will encapsulate the root cause. This is a runtime exception (unchecked exception) to facilitate ease of programming when implementing services. Any called function in a server service implementation can throw this exception and it will be propagated all the way to the client. Example of server side implementation:

   ServiceException e = new ServiceException(ServiceException.CODE_ADMIN_GATEWAY_ALREADY_CONNECTED);
   throw e;
 
The client can use resultCode and message to perform further error processing or to display the message to the user. Example of client side processing:
  serverAdminClient.setGateway(nonExistentComPort);
  try {
      serverAdminClient.connectGateway();
  } catch (ServiceException e) {
      System.out.println("Can't connect to port " + nonExistentComPort);
      System.out.println("Error code: " + e.getResultCode());
      System.out.println("Error message: " + e.getMessage());
  }
 

See Also:
Serialized Form

Field Summary
static int CODE_ADMIN_GATEWAY_ALREADY_CONNECTED
           
static int CODE_ADMIN_GATEWAY_FAILED_TO_CONNECT
           
static int CODE_ADMIN_GATEWAY_FAILED_TO_DISCONNECT
           
static int CODE_ADMIN_GATEWAY_NOT_SET
           
static int CODE_INVALID_ARGUMENT
           
static int CODE_SERVER_INIT_FAILED
           
static int CODE_SERVICE_EXEC_FAILED
           
static int CODE_SERVICE_UNRECOGNIZED_REQUEST
           
private static Logger logger
           
private static Map<Integer,String> messages
           
(package private)  int resultCode
          Result code for the service call.
private static long serialVersionUID
           
 
Constructor Summary
ServiceException(int resultCode)
           
ServiceException(int resultCode, String msg)
           
ServiceException(int resultCode, String msg, Throwable rootCause)
           
ServiceException(int resultCode, Throwable rootCause)
           
 
Method Summary
 String getCodeMessage()
          Return a human readable message for this.resultCode.
static String getCodeMessage(int code)
          Return a human readable message for given code.
 int getResultCode()
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private static final Logger logger

resultCode

int resultCode
Result code for the service call.


serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

CODE_INVALID_ARGUMENT

public static final int CODE_INVALID_ARGUMENT
See Also:
Constant Field Values

CODE_SERVER_INIT_FAILED

public static final int CODE_SERVER_INIT_FAILED
See Also:
Constant Field Values

CODE_SERVICE_EXEC_FAILED

public static final int CODE_SERVICE_EXEC_FAILED
See Also:
Constant Field Values

CODE_SERVICE_UNRECOGNIZED_REQUEST

public static final int CODE_SERVICE_UNRECOGNIZED_REQUEST
See Also:
Constant Field Values

CODE_ADMIN_GATEWAY_ALREADY_CONNECTED

public static final int CODE_ADMIN_GATEWAY_ALREADY_CONNECTED
See Also:
Constant Field Values

CODE_ADMIN_GATEWAY_NOT_SET

public static final int CODE_ADMIN_GATEWAY_NOT_SET
See Also:
Constant Field Values

CODE_ADMIN_GATEWAY_FAILED_TO_CONNECT

public static final int CODE_ADMIN_GATEWAY_FAILED_TO_CONNECT
See Also:
Constant Field Values

CODE_ADMIN_GATEWAY_FAILED_TO_DISCONNECT

public static final int CODE_ADMIN_GATEWAY_FAILED_TO_DISCONNECT
See Also:
Constant Field Values

messages

private static Map<Integer,String> messages
Constructor Detail

ServiceException

public ServiceException(int resultCode,
                        String msg,
                        Throwable rootCause)

ServiceException

public ServiceException(int resultCode,
                        String msg)

ServiceException

public ServiceException(int resultCode)

ServiceException

public ServiceException(int resultCode,
                        Throwable rootCause)
Method Detail

getCodeMessage

public static String getCodeMessage(int code)
Return a human readable message for given code.


getCodeMessage

public String getCodeMessage()
Return a human readable message for this.resultCode.


getResultCode

public int getResultCode()


Copyright © 2007 Sentilla, Inc. All Rights Reserved.