How to throw exception w/RMI from Server->Client w/o "nested exception..." mentioned
I have a Server throwing a custom exception defined:
Code:
package class.project;
import java.rmi.RemoteException;
public class SecurityException extends RemoteException {
/**
* Serializable class SecurityException requires declaring a static final serialVersionUID field of type long
*/
private static final long serialVersionUID = 1L;
/**
* Constructor used to pass msg String argument up to Exception class constructor.
*
* @param msg String argument 'msg' passed up to Exception class constructor
*/
public SecurityException(String msg) {
super(msg);
}
}
to the Client via RMI, where the Client attempts to display the SecurityException:
Code:
public static void performTestOne(ATM atm) {
try {
atm.getBalance(getAccountInfo(0000001, 5555));
} catch (Exception e) {
System.out.println("Failed as expected: "+e);
}
}
And I am wondering how to only display the SecurityException details provided by the Server:
Code:
if ( !this.security.authenticateTransaction(account_info, account) ) {
throw new SecurityException( "Unable to authenticate transaction. Invalid username/password combination." );
}
Unfortunately I am getting the following output:
Quote:
Failed as expected: java.rmi.ServerException: RemoteException occurred in server thread; nested e
xception is:
class.project.SecurityException: Unable to authenticate transaction. Invalid username
/password combination.
What I need to see is:
Quote:
Failed as expected: class.project.SecurityException: Unable to authenticate transaction. Invalid username
/password combination.