title: Java - overriding Object's toString() method, but I have to throw exceptions
body: <p>I have run into an issue where I have to override Object's toString() method, but the original method doesn't throw any exceptions. However, I am using some generic code that requires exceptions to be thrown.</p>
  
  <pre><code>public String toString() throws EmptyListException, InvalidPositionException
  {
      Position&lt;Entry&lt;E&gt;&gt; current = fList.first();
      StringBuilder str = new StringBuilder();
      for(int i = 0; i &lt; size(); i++)
      {
          try
          {
              str.insert(str.length(), current.element().toString() + " ");
              current = fList.next(current);
          }
          catch(Exception e){}
      }
      return str.toString();
  }
  </code></pre>
  
  <p>This is part of FavoriteList.java. These exceptions HAVE to be thrown. If there is any way to somehow suppress these exceptions or catch them inside the method, that would be helpful. </p>
  
  <p>In the end, my method header has to look like this:</p>
  
  <pre><code>public String toString()
  { content }
  </code></pre>
  
  <p>I don't care about the ending content of the method. As long as it compiles I am fine. I just need to fix the header, but I can't find a way to fix it.
  Thank you very much in advance.</p>