title: Extending the Exception class in Dart
body: <p>I keep getting an error when I try to extend the Exception class and can't figure out why.
  Here is the code for my custom exception:</p>
  
  <pre class="lang-dart prettyprint-override"><code>class MyException extends Exception {
    String msg;
    MyException(this.msg);
    String toString() =&gt; 'FooException: $msg';
  }
  </code></pre>
  
  <p>The error resolves around the constructor. It complains that "The generative constructor 'Exception([dynamic message]) -> Exception' expected, but factory found". How do I fix this?</p>