From 9a113de24244e5aa850e501982947396c5db504f Mon Sep 17 00:00:00 2001 From: Plague Fox Date: Sun, 23 Jul 2023 17:05:19 +0400 Subject: [PATCH] Add stack_trace --- .vscode/tasks.json | 2 +- examples/console/bin/main.dart | 2 +- lib/src/client/centrifuge.dart | 8 +++++++- pubspec.yaml | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 2e20a5c..845e925 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -107,7 +107,7 @@ "centrifugo", "gentoken", "--user=dart", - "--ttl=604800000" // 604800 + "--ttl=604800" ], "group": { "kind": "none", diff --git a/examples/console/bin/main.dart b/examples/console/bin/main.dart index 4a0f628..f28933e 100644 --- a/examples/console/bin/main.dart +++ b/examples/console/bin/main.dart @@ -37,7 +37,7 @@ void main([List? args]) { // e.g. `client.states.connected` client.states.listen((state) => print('State changed to: $state')); - // Handle all centrifuge errors. + // Handle all centrifuge exceptions. client.errors.listen( (error) => print( 'Exception: ${error.exception}, ' diff --git a/lib/src/client/centrifuge.dart b/lib/src/client/centrifuge.dart index 25938ab..a24dfca 100644 --- a/lib/src/client/centrifuge.dart +++ b/lib/src/client/centrifuge.dart @@ -9,6 +9,7 @@ import 'package:centrifuge_dart/src/transport/transport_interface.dart'; import 'package:centrifuge_dart/src/transport/ws_protobuf_transport.dart'; import 'package:centrifuge_dart/src/util/logger.dart' as logger; import 'package:meta/meta.dart'; +import 'package:stack_trace/stack_trace.dart' as st; /// {@template centrifuge} /// Centrifuge client. @@ -74,7 +75,12 @@ base mixin CentrifugeErrorsMixin on CentrifugeBase { @protected @nonVirtual void _emitError(CentrifugeException exception, StackTrace stackTrace) => - _errorsController.add((exception: exception, stackTrace: stackTrace)); + _errorsController.add( + ( + exception: exception, + stackTrace: st.Trace.from(stackTrace).terse, + ), + ); late final StreamController< ({CentrifugeException exception, StackTrace stackTrace})> diff --git a/pubspec.yaml b/pubspec.yaml index d0ac796..8ffb278 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -52,6 +52,7 @@ dependencies: # Utilities crypto: ^3.0.3 fixnum: ^1.1.0 + stack_trace: ^1.11.1 dev_dependencies: build_runner: ^2.4.6