Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ class StreamFeedsNetworkError extends StreamFeedsError {
factory StreamFeedsNetworkError.fromDioError(DioError error) {
final response = error.response;
ErrorResponse? errorResponse;
final data = json.decode(response?.data);
if (data != null) {
errorResponse = ErrorResponse.fromJson(data);
if (response?.data != null) {
errorResponse = ErrorResponse.fromJson(json.decode(response!.data));
}
return StreamFeedsNetworkError.raw(
code: errorResponse?.code ?? -1,
Expand Down
14 changes: 14 additions & 0 deletions packages/stream_feed/test/stream_feeds_error_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ void main() {
expect(error.message, message);
});

test('time out', () {
const message = 'Connecting timed out [0ms]';
final options = RequestOptions(path: 'test-path');

final dioError = DioError(
requestOptions: options,
error: 'Connecting timed out [${options.connectTimeout}ms]',
type: DioErrorType.connectTimeout,
);
final error = StreamFeedsNetworkError.fromDioError(dioError);
expect(error, isNotNull);
expect(error.message, message);
});

test('.fromDioError', () {
const code = 333;
const statusCode = 666;
Expand Down