Eremis
October 9th, 2010, 10:13 PM
Hi everybody,
I have an assignment where I need to create an Exception which extends regular java.lang.Exception, which catches all ChargenServer related exceptions in one... (For ex. socket related exceptions, etc...)
This is all a part of a "big project" in which I need to create both server and client java applications for Chargen. (Both UDP and TCP implementations).
For some background... I am a freshman CS and I am in Networking, because i tested out of Java, so I never really "covered" everything in java... (Self-tough myself java) I understand how to use exceptions, but I just need help writing this one.
This is the description what this exception needs to have...:
The exceptions generated by the various concrete implementations of the ChargenServer interface’s listen()
method vary across implementations. For example, a TCP implementation might throw exceptions related
to TCP socket errors; a UDP implementation might throw other exceptions. We do not want users of
our interface to have to explicitly catch all these exceptions. (Remember, an interface presents an abstract
view of the component.) If a user is using only the UDP implementation, why make them catch TCP-
related exceptions? Instead, to provide an abstract interface, we introduce ChargenServerException. Classes
that provide concrete implementations of listen() will catch the protocol-specific exceptions, wrap those
exceptions in a ChargenServerException, and then throw that exception. This approach passes along all the
error information in the wrapped object, but keeps the interface “clean”.
Can someone help me, by maybie giving an example such as making mathOperationsExcpetion which catches multiple "math operations exceptions..."
or simply show me how to do this one...
Thanks
PS
I attached a UML diagram picture of the entire "server" side of this project...
I have an assignment where I need to create an Exception which extends regular java.lang.Exception, which catches all ChargenServer related exceptions in one... (For ex. socket related exceptions, etc...)
This is all a part of a "big project" in which I need to create both server and client java applications for Chargen. (Both UDP and TCP implementations).
For some background... I am a freshman CS and I am in Networking, because i tested out of Java, so I never really "covered" everything in java... (Self-tough myself java) I understand how to use exceptions, but I just need help writing this one.
This is the description what this exception needs to have...:
The exceptions generated by the various concrete implementations of the ChargenServer interface’s listen()
method vary across implementations. For example, a TCP implementation might throw exceptions related
to TCP socket errors; a UDP implementation might throw other exceptions. We do not want users of
our interface to have to explicitly catch all these exceptions. (Remember, an interface presents an abstract
view of the component.) If a user is using only the UDP implementation, why make them catch TCP-
related exceptions? Instead, to provide an abstract interface, we introduce ChargenServerException. Classes
that provide concrete implementations of listen() will catch the protocol-specific exceptions, wrap those
exceptions in a ChargenServerException, and then throw that exception. This approach passes along all the
error information in the wrapped object, but keeps the interface “clean”.
Can someone help me, by maybie giving an example such as making mathOperationsExcpetion which catches multiple "math operations exceptions..."
or simply show me how to do this one...
Thanks
PS
I attached a UML diagram picture of the entire "server" side of this project...