title: RMI and exceptions
body: <p>I am new to using RMI and I am relatively new to using exceptions.</p>
  
  <p>I want to be able to throw an exception over RMI (is this possible?)</p>
  
  <p>I have a simple server which serves up students and I have delete method which if the student doesn't exist I want  to throw a custom exception of StudentNotFoundException which extends RemoteException (is this a good thing to do?)</p>
  
  <p>Any advice or guidance would be greatly appreciated.</p>
  
  <p>Server Interface method</p>
  
  <pre><code>    /**
   * Delete a student on the server
   * 
   * @param id of the student
   * @throws RemoteException
   * @throws StudentNotFoundException when a student is not found in the system
   */
  void removeStudent(int id) throws RemoteException, StudentNotFoundException;
  </code></pre>
  
  <p>Server method implementation </p>
  
  <pre><code>    @Override
  public void removeStudent(int id) throws RemoteException, StudentNotFoundException
  {
      Student student = studentList.remove(id);
  
      if (student == null)
      {
          throw new StudentNotFoundException("Student with id:" + id + " not found in the system");
      }
  }
  </code></pre>
  
  <p>Client method</p>
  
  <pre><code>    private void removeStudent(int id) throws RemoteException
  {
      try
      {
          server.removeStudent(id);
          System.out.println("Removed student with id: " + id);
      }
      catch (StudentNotFoundException e)
      {
          System.out.println(e.getMessage());
      }
  
  }
  </code></pre>
  
  <p>StudentNotFoundException </p>
  
  <pre><code>package studentserver.common;
  
  import java.rmi.RemoteException;
  
  public class StudentNotFoundException extends RemoteException
  {
      private static final long serialVersionUID = 1L;
  
      public StudentNotFoundException(String message)
      {
          super(message);
      }
  }
  </code></pre>
  
  <p>Thank you for your reply I have now managed to fix my problem and realised that extending RemoteException was bad idea.</p>