Use ThrowingReflector
This commit is contained in:
parent
650cf208fc
commit
6d71707673
2 changed files with 16 additions and 7 deletions
|
@ -3,6 +3,8 @@
|
|||
* Add `allowHttp1` to `AngelHttp2` constructors. https://github.com/angel-dart/angel/issues/108
|
||||
* Add `deserializeBody` and `decodeBody` to `RequestContext`. https://github.com/angel-dart/angel/issues/109
|
||||
* Add `HostnameRouter`, which allows for routing based on hostname. https://github.com/angel-dart/angel/issues/110
|
||||
* Default to using `ThrowingReflector`, instead of `EmptyReflector`. This will give a more descriptive
|
||||
error when trying to use controllers, etc. without reflection enabled.
|
||||
|
||||
# 2.0.4
|
||||
* Prepare for Dart SDK change to `Stream<List<int>>` that are now
|
||||
|
|
|
@ -355,21 +355,28 @@ class Angel extends Routable {
|
|||
return super.use(path, service)..app = this;
|
||||
}
|
||||
|
||||
static const String _reflectionErrorMessage =
|
||||
ThrowingReflector.defaultErrorMessage + ' ' + _reflectionInfo;
|
||||
|
||||
static const String _reflectionInfo =
|
||||
'Features like controllers, constructor dependency injection, and `ioc` require reflection, '
|
||||
'and will not work without it.\n\n'
|
||||
'For more, see the documentation:\n'
|
||||
'https://docs.angel-dart.dev/guides/dependency-injection#enabling-dart-mirrors-or-other-reflection';
|
||||
|
||||
Angel(
|
||||
{Reflector reflector = const EmptyReflector(),
|
||||
{Reflector reflector =
|
||||
const ThrowingReflector(errorMessage: _reflectionErrorMessage),
|
||||
this.environment = angelEnv,
|
||||
this.logger,
|
||||
this.allowMethodOverrides = true,
|
||||
this.serializer,
|
||||
this.viewGenerator})
|
||||
: super(reflector) {
|
||||
if (reflector == const EmptyReflector()) {
|
||||
if (reflector is EmptyReflector || reflector is ThrowingReflector) {
|
||||
var msg =
|
||||
'No `reflector` was passed to the Angel constructor, so reflection will not be available.\n'
|
||||
'Features like controllers, constructor dependency injection, and `ioc` require reflection, '
|
||||
'and will not work without it.\n\n'
|
||||
'For more, see the documentation:\n'
|
||||
'https://docs.angel-dart.dev/guides/dependency-injection#enabling-dart-mirrors-or-other-reflection';
|
||||
'No `reflector` was passed to the Angel constructor, so reflection will not be available.\n' +
|
||||
_reflectionInfo;
|
||||
logger?.warning(msg);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue