Julho 06
Prof(s). Eduardo Bezerra & Ismael H. F. Santos                                                2
Best Practices for Designing API (cont.)
3.Try not to create new custom exceptions if they do not have useful information for client code.
npublic class DuplicateUsernameException extends Exception{}
n
nThe new version provides two useful methods: requestedUsername(), which returns the requested name, and availableNames(), which returns an array of available usernames similar to the one requested.
npublic class DuplicateUsernameException extends Exception {
n  public DuplicateUsernameException (String username){....}
n  public String requestedUsername(){...}
n  public String[] availableNames(){...}
n}