How to organize Exception classes without code duplication?
<p>I have a number of custom <code>Exception</code>-inheriting classes in my package, which do not differ from their base class. The only purpose I have them is to distinguish one exception cause from the other, when it is thrown. This is how one of my Exception class looks like:</p>

<pre><code>package com.XXX;
/**
 * Thrown when query format is invalid.
 */
public class InvalidFormatException extends Exception {
  /**
   * Public ctor.
   * @param m Supplementary message
   */
  public InvalidFormatException(final String m) {
    super(m);
  }
}
</code></pre>

<p>The problem is that all classes are absolutely identical, like twins. The only thing which is different is their names. I don't like this situation, since it's an obvious code duplication. In other languages (like PHP, Python, etc.) I would declare these classes on-fly during runtime, but Java doesn't allow this, as well as I understand. Is there any workaround?</p>
