abstract class Foo {
factory Foo([var message]) => new _Object();
}
class Bar<T> extends Foo {
}
[error] The generative constructor ‘Foo([dynamic message]) → Foo’ expected, but factory found (test.dart, line 5, col 7)
This error message is really unclear, especially if you’ve never seen the actual definition of class Foo (and even then, if you’re not particularly familiar with Dart).
I would have been less confused with the following message, or something like it:
“Class Bar extends abstract class Foo which declares a factory ‘Foo([dynamic message]) → Foo’, but class Bar doesn’t provide an implementation for that factory.”
I guess the message should really be “Class Bar extends abstract class Foo which does not declare a generative constructor and therefore cannot be extended”, or something?
Can https://www.dartlang.org/guides/language/language-tour#exceptions and https://api.dartlang.org/stable/2.2.0/dart-core/Exception-class.html provide an example of how to create a custom
Exception
? I’m presuming the correct approach is to useMyException implements Exception
rather than... extends Exception
, but I don’t see anything in the documentation providing guidance on that.