
/*
 * Server to test the behavior of user-defined and 
 * system exceptions
 */

import java.io.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;


public class ExceptionTestImpl extends Exceptions.ExceptionTestPOA {
	
  //Implement method which throws our user-defined exception
  public void throwAUserException() 
	throws Exceptions.UserException1
  {
	if(true)
	{
		System.out.println("Throw a user exception back at the orb");
		Exceptions.UserException1 ex = 
			new Exceptions.UserException1();
		ex.reason = "This is the reason from the server";
		ex.code = 111;
		throw ex;
	}
  }

  //Implement method which throws a runtime exception.  
  //Just for fun, let's walk-off the end of an array
  //and cause an ArrayIndexOutOfBounds exception (a common
  //runtime exception)
  public void throwARuntimeException()
  {
	System.out.println("Throw a runtime exception back at the orb");
	byte[] bytes = new byte[1];
	bytes[2] = (byte) 1;//There is no index[2]
  }
}

