Skip to content

Commit

Permalink
Merge pull request #17 from playx-flutter/qa
Browse files Browse the repository at this point in the history
feat:Update to v0.2.3 - CU-86c0f1hbw
  • Loading branch information
basemosama authored Dec 15, 2024
2 parents f4d7cd4 + d0b8536 commit 7b63507
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.2.3
- fix: Bug causing error not being reported successfully.
- feat: Update `sentry_dio`package to v8.11.0.

## 0.2.2
- Add ability to download content using dio `download` method.

Expand Down
2 changes: 1 addition & 1 deletion lib/playx_network.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library playx_network;
library;

export 'package:dio/dio.dart';
export 'package:dio/io.dart';
Expand Down
31 changes: 21 additions & 10 deletions lib/src/handler/api_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,26 @@ import 'package:playx_network/src/utils/utils.dart';

/// parses json to object in isolate.
Future<T> _parseJsonInIsolate<T>(List<dynamic> args) async {
final data = args[0];
final JsonMapper<T> fromJson = args[1];
return fromJson(data);
try {
final data = args[0];
final JsonMapper<T> fromJson = args[1];
return fromJson(data);
} catch (e, s) {
ApiHandler.printError(text: e.toString(), stackTrace: s.toString());
rethrow;
}
}

/// parses json list to list of objects in isolate.
Future<List<T>> _parseJsonListInIsolate<T>(List<dynamic> args) async {
final data = args[0] as List;
final JsonMapper<T> fromJson = args[1];
return await Future.wait(data.map((item) async => await fromJson(item)));
try {
final data = args[0] as List;
final JsonMapper<T> fromJson = args[1];
return await Future.wait(data.map((item) async => await fromJson(item)));
} catch (e, s) {
ApiHandler.printError(text: e.toString(), stackTrace: s.toString());
rethrow;
}
}

// ignore: avoid_classes_with_only_static_members
Expand Down Expand Up @@ -88,7 +98,7 @@ class ApiHandler {
final result = await compute(_parseJsonInIsolate, [data, fromJson]);
return NetworkResult.success(result);
// ignore: avoid_catches_without_on_clauses
} on Exception catch (e, s) {
} catch (e, s) {
_printError(
header: 'Playx Network Error :',
text: e.toString(),
Expand All @@ -104,7 +114,7 @@ class ApiHandler {
}
}
// ignore: avoid_catches_without_on_clauses
} on Exception catch (e, s) {
} catch (e, s) {
_printError(
header: 'Playx Network Error :',
text: e.toString(),
Expand Down Expand Up @@ -183,7 +193,7 @@ class ApiHandler {
statusCode: -1));
}
// ignore: avoid_catches_without_on_clauses
} on Exception catch (e, s) {
} catch (e, s) {
_printError(
header: 'Playx Network Error :',
text: e.toString(),
Expand All @@ -199,7 +209,7 @@ class ApiHandler {
}
}
// ignore: avoid_catches_without_on_clauses
} on Exception catch (e, s) {
} catch (e, s) {
_printError(
header: 'Playx Network Error :',
text: e.toString(),
Expand Down Expand Up @@ -452,6 +462,7 @@ class ApiHandler {
}

static void printError({String? header, String? text, String? stackTrace}) {
if (kReleaseMode) return;
const maxWidth = 90;
//ignore: avoid_print
print('');
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: playx_network
description: playx_network is a Wrapper around Dio that can perform api request with better error handling and easily get the result of any api request.
version: 0.2.2
version: 0.2.3
homepage: https://sourcya.com/
repository: https://github.com/playx-flutter/playx_network
issue_tracker: https://github.com/playx-flutter/playx_network/issues
Expand All @@ -20,7 +20,7 @@ dependencies:
sdk: flutter
dio: ^5.7.0
pretty_dio_logger: ^1.4.0
sentry_dio: ^8.9.0
sentry_dio: ^8.11.0

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 7b63507

Please sign in to comment.