SDSU CS 596 Client-Server Programming
User Defined Exceptions

[To Lecture Notes Index]
San Diego State University -- This page last updated February 6, 1996
----------

User Defined Exceptions
class  BoringLectureException  extends  Exception  {

	public  BoringLectureException()  {
		super();
	}

	public  BoringLectureException( String  errorMessage )  {
		super(  errorMessage  );
	}
}


class  NewExceptionTest  {

	public static void dullSpeaker() throws BoringLectureException {
		// Code can go here
		throw  new  BoringLectureException(  "Change Topics"  );
	}

	public  static  void  main(  String  args[]  )	{

		try  {
			dullSpeaker();

		} catch  (  BoringLectureException  e  )  {

			System.err.println( "Error: Time to "  +  e.getMessage() );
		}
	}
}
Output
Error: Time to Change Topics
----------