Observable.onError处理程序不会阻止异常终止应用程序

时间:2019-01-09 10:31:41

标签: flutter dart-async rxdart

更新了密码

我对调试这些错误没有结果感到厌倦 任何人都知道错???!?!!?!

当添加的Stream发出正常事件时,它工作正常,但是在发出错误时,它由onErorr方法处理,并且如您在StackTrace中看到的那样,发生了奇怪的错误。

test("Testing the Stream", () async {

 final _categoriesInfosSubject = new PublishSubject<String>();
 var errorThrown = false;

 Observable<String>  categories$ = _categoriesInfosSubject.stream;
 categories$.listen(any, onError: (err){ print("ErrorHappened"); errorThrown = true;});

 await _categoriesInfosSubject.addStream(
  Observable.error(Error()),
 );
 await Future.delayed(Duration(seconds: 2), (){});
 expect(errorThrown , true);

});
   
ErrorHappened
dart:async                                              _Completer.completeError
package:rxdart/src/subjects/subject.dart 101:19         Subject.addStream. 
<fn>
===== asynchronous gap ===========================
dart:async                                              _StreamImpl.listen
package:rxdart/src/streams/error.dart 25:30             ErrorStream.listen
package:rxdart/src/observables/observable.dart 1729:20  Observable.listen
package:rxdart/src/subjects/subject.dart 94:12          Subject.addStream
test\home_screen\home_bloc.dart 77:35                   main.<fn>

Instance of 'Error'

0 个答案:

没有答案