Change back to Object from dynamic (#66)
See https://github.com/dart-lang/stack_trace/pull/64#discussion_r410279004
Enable and fix the lint `avoid_private_typedef_functions`.
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 @@
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 @@
///
/// If [callback] returns a value, it will be returned by [capture] as well.
static T capture<T>(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 '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 @@
///
/// 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;