Sdk: Confusing error message when inheriting from an abstract class with a factory without providing a factory

Created on 11 Feb 2015  Â·  5Comments  Â·  Source: dart-lang/sdk

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."

P2 analyzer-ux area-analyzer type-bug

Most helpful comment

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 use MyException implements Exception rather than ... extends Exception, but I don't see anything in the documentation providing guidance on that.

All 5 comments

_Removed Priority-Unassigned label._
_Added Priority-Medium, Area-Analyzer, Triaged labels._

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 use MyException implements Exception rather than ... extends Exception, but I don't see anything in the documentation providing guidance on that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nex3 picture nex3  Â·  3Comments

brooth picture brooth  Â·  3Comments

bergwerf picture bergwerf  Â·  3Comments

ranquild picture ranquild  Â·  3Comments

DartBot picture DartBot  Â·  3Comments