Specifications
Sun Services
Java™ Programming Language
Module 8, slide 17 of 25
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Creating Your Own Exceptions
1 public class ServerTimedOutException extends Exception {
2 private int port;
3
4 public ServerTimedOutException(String message, int port) {
5 super(message);
6 this.port = port;
7 }
8
9 public int getPort() {
10 return port;
11 }
12 }
Use the getMessage method, inherited from the Exception
class, to get the reason for which the exception was made.










