title: Throw anonymous exceptions in Java
body: <p>It is possible in Java to throw any Exception even if it is just declared on moment of throwing, example below:</p>
  
  <pre><code>import org.springframework.dao.DataAccessException;
  
   // DataAccessException - is abstract class
  
   } catch (DataAccessException dae) {
        throw new DataAccessException("Exception while executing SQL: \n" + sql
              +    "\nparams: " + paramsToString(params), dae) {
                            private static final long serialVersionUID = 1L;
        };
   } 
  </code></pre>
  
  <p>Please share your ideas how bad or good this approach.</p>
  
  <p>the same question to extending RuntimeException (that is not abstract) and throw it right away.</p>