From 7a4ea60efab0f86779fee0e6b8a3af0eb33e3041 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Fri, 17 Apr 2020 09:48:12 -0700 Subject: [PATCH] Change back to Object from dynamic See https://github.com/dart-lang/stack_trace/pull/64#discussion_r410279004 Enable and fix the lint `avoid_private_typedef_functions`. --- CHANGELOG.md | 3 +++ analysis_options.yaml | 4 ++++ lib/src/chain.dart | 2 +- lib/src/stack_zone_specification.dart | 5 +---- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index faf6eeb..39e7fb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ ## 1.9.4-dev * Added support for firefox anonymous stack traces +* Change the argument type to `Chain.capture` from `Function(dynamic, Chain)` to + `Function(Object, Chain)`. Existing functions which take `dynamic` are still + fine, but new uses can have a safer type. ## 1.9.3 diff --git a/analysis_options.yaml b/analysis_options.yaml index 2762c70..70216af 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -4,3 +4,7 @@ analyzer: implicit-casts: false errors: prefer_spread_collections: ignore + +linter: + rules: + - avoid_private_typedef_functions diff --git a/lib/src/chain.dart b/lib/src/chain.dart index 48ac2d9..602b90c 100644 --- a/lib/src/chain.dart +++ b/lib/src/chain.dart @@ -73,7 +73,7 @@ class Chain implements StackTrace { /// /// If [callback] returns a value, it will be returned by [capture] as well. static T capture(T Function() callback, - {void Function(dynamic error, Chain) onError, + {void Function(Object error, Chain) onError, bool when = true, bool errorZone = true}) { if (!errorZone && onError != null) { diff --git a/lib/src/stack_zone_specification.dart b/lib/src/stack_zone_specification.dart index 4ac6604..f721e94 100644 --- a/lib/src/stack_zone_specification.dart +++ b/lib/src/stack_zone_specification.dart @@ -10,9 +10,6 @@ import 'lazy_trace.dart'; import 'trace.dart'; import 'utils.dart'; -/// A function that handles errors in the zone wrapped by [Chain.capture]. -typedef _ChainHandler = void Function(dynamic error, Chain chain); - /// A class encapsulating the zone specification for a [Chain.capture] zone. /// /// Until they're materialized and exposed to the user, stack chains are tracked @@ -56,7 +53,7 @@ class StackZoneSpecification { /// /// If this is null, that indicates that any unhandled errors should be passed /// to the parent zone. - final _ChainHandler _onError; + final void Function(Object error, Chain) _onError; /// The most recent node of the current stack chain. _Node _currentNode;