Skip to content

Conversation

@spkersten
Copy link
Collaborator

@spkersten spkersten commented Feb 7, 2025

Dematerialize exceptions inside readCharacteristic instead of in some stream transformation so the stack trace is the one for the call to readCharacteristic (ending in the user's code that initiated the read that failed) instead of some generic list of stream handling methods.

After:

flutter: Exception: GenericFailure<CharacteristicValueUpdateError>(code: CharacteristicValueUpdateError.unknown, message: "boom")
flutter: #0      Result.dematerialize.<anonymous closure> (package:reactive_ble_platform_interface/src/model/result.dart:22:13)
flutter: #1      Result.iif (package:reactive_ble_platform_interface/src/model/result.dart:34:21)
flutter: #2      Result.dematerialize (package:reactive_ble_platform_interface/src/model/result.dart:15:28)
flutter: #3      ConnectedDeviceOperationImpl.readCharacteristic (package:flutter_reactive_ble/src/connected_device_operation.dart:62:19)
flutter: <asynchronous suspension>
flutter: #4      MyBleClient._bindConnectedDevice (package:ble_client/src/example/example.dart:766:5)

Before:

flutter: Exception: GenericFailure<CharacteristicValueUpdateError>(code: CharacteristicValueUpdateError.unknown, message: "boom")
flutter: #0      Result.dematerialize.<anonymous closure> (package:reactive_ble_platform_interface/src/model/result.dart:22:13)
flutter: #1      Result.iif (package:reactive_ble_platform_interface/src/model/result.dart:34:21)
flutter: #2      Result.dematerialize (package:reactive_ble_platform_interface/src/model/result.dart:15:28)
flutter: #3      ConnectedDeviceOperationImpl.readCharacteristic.<anonymous closure> (package:flutter_reactive_ble/src/connected_device_operation.dart:51:172)
flutter: #4      _MapStream._handleData (dart:async/stream_pipe.dart:211:31)
flutter: #5      _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:151:13)
flutter: #6      _rootRunUnary (dart:async/zone.dart:1422:47)
flutter: #7      _CustomZone.runUnary (dart:async/zone.dart:1324:19)
flutter: #8      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1233:7)
flutter: #9      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:366:11)
flutter: #10     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:297:7)
flutter: #11     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:121:11)
flutter: #12     _WhereStream._handleData (dart:async/stream_pipe.dart:193:12)
flutter: #13     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:151:13)
flutter: #14     _rootRunUnary (dart:async/zone.dart:1422:47)
flutter: #15     _CustomZone.runUnary (dart:async/zone.dart:1324:19)
flutter: #16     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1233:7)
flutter: #17     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:366:11)
flutter: #18     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:297:7)
flutter: #19     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:121:11)

… stream transformation

so the stack trace is the one for the call to readCharacteristic (ending in the user's code
that initiated the read that failed) instead of some generic list of stream handling methods.
@spkersten spkersten merged commit fab66c2 into PhilipsHue:master Feb 7, 2025
2 checks passed
@spkersten spkersten deleted the improve-stack-trace-of-read branch February 7, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants