title: How can one combine overriding with stackable traits in Scala?
body: <p>In Swing and Wicket applications it is normal to override methods in classes that are provided by the framework. For example:</p>
  
  <pre><code>val form = new Form("form") {
    override def onSubmit() { println("Form was submitted") }
  }
  </code></pre>
  
  <p>Where for the example Form can be defined as:</p>
  
  <pre><code>abstract class Form(id: String) {
    def onSubmit()
    def error(msg: String) { println(msg) }
  }
  </code></pre>
  
  <p>Many form implementation need error handling. For this I created a stackable trait:</p>
  
  <pre><code>trait FormErrorHandler extends Form {
    abstract override def onSubmit() {
      try super.onSubmit()
      catch { case e: Exception =&gt; error("error during submit " + e.getMessage) }
    }
  }
  </code></pre>
  
  <p>If I now try to combine this I get compiler errors:</p>
  
  <pre><code>val form = new Form("form") {
    override def onSubmit() { println("Form was submitted") }
  } with FormErrorHandler // DOES NOT COMPILE
  </code></pre>
  
  <p>I worked around it with:</p>
  
  <pre><code>class MyForm extends Form("form") {
    override def onSubmit() { println("Form was submitted") }
  }
  val form = new MyForm with FormErrorHandler
  </code></pre>
  
  <p>but it just doesn't read as well; I have to name a class that is normally anonymous.</p>
  
  <p>Any suggestions to make this look nice?
  Would the syntax construct I tried make sense for a future Scala version?</p>