File tree Expand file tree Collapse file tree 3 files changed +18
-10
lines changed
packages/common_client/lib/src/data_sources Expand file tree Collapse file tree 3 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import 'dart:math';
55
66import '../config/data_source_config.dart' ;
77import 'data_source.dart' ;
8+ import 'data_source_status.dart' ;
89import 'requestor.dart' ;
910
1011HttpClient _defaultHttpClientFactory (HttpProperties httpProperties) {
@@ -100,14 +101,17 @@ final class PollingDataSource implements DataSource {
100101 _eventController.sink.add (event);
101102 case StatusEvent ():
102103 _eventController.sink.add (event);
104+ final suffix = event.shutdown ? 'stopping polling' : 'will retry' ;
105+ final message = event.kind == ErrorKind .errorResponse
106+ ? 'received unexpected status code when polling'
107+ : 'encountered error with polling request' ;
108+ final argument = event.kind == ErrorKind .errorResponse
109+ ? event.statusCode
110+ : event.message;
111+ _logger.error ('$message : $argument , $suffix ' );
103112 if (event.shutdown) {
104- _logger.error (
105- 'received unexpected status code when polling: ${event .statusCode }, stopping polling' );
106113 _permanentShutdown = true ;
107114 stop ();
108- } else {
109- _logger.error (
110- 'received unexpected status code when polling: ${event .statusCode }, will retry' );
111115 }
112116 }
113117
Original file line number Diff line number Diff line change @@ -63,7 +63,6 @@ final class Requestor {
6363 body: _method != RequestMethod .get ? _contextString : null );
6464 return await _handleResponse (res);
6565 } catch (err) {
66- _logger.error ('encountered error with polling request: $err , will retry' );
6766 return StatusEvent (ErrorKind .networkError, null , err.toString ());
6867 }
6968 }
@@ -91,10 +90,10 @@ final class Requestor {
9190 return DataEvent ('put' , res.body, environmentId: environmentId);
9291 } else {
9392 if (isHttpGloballyRecoverable (res.statusCode)) {
94- return StatusEvent (ErrorKind .networkError , res.statusCode,
93+ return StatusEvent (ErrorKind .errorResponse , res.statusCode,
9594 'Received unexpected status code: ${res .statusCode }' );
9695 } else {
97- return StatusEvent (ErrorKind .networkError , res.statusCode,
96+ return StatusEvent (ErrorKind .errorResponse , res.statusCode,
9897 'Received unexpected status code: ${res .statusCode }' ,
9998 shutdown: true );
10099 }
Original file line number Diff line number Diff line change @@ -166,8 +166,13 @@ final class StreamingDataSource implements DataSource {
166166 case DataEvent ():
167167 _dataController.sink.add (res);
168168 case StatusEvent ():
169- _logger.error (
170- 'received unexpected status code when polling in response to a ping event: ${res .statusCode }' );
169+ final message = res.kind == ErrorKind .errorResponse
170+ ? 'received unexpected status code when polling in response to a ping event'
171+ : 'encountered error with polling request in response to a ping event' ;
172+ final argument = res.kind == ErrorKind .errorResponse
173+ ? res.statusCode
174+ : res.message;
175+ _logger.error ('$message : $argument ' );
171176 _dataController.sink.add (res);
172177 }
173178 } else {
You can’t perform that action at this time.
0 commit comments