com.sentilla.host.client.admin
Class ServiceException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
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
Methods inherited from class java.lang.Throwable |
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
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
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)
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.