Skip to content

Commit

Permalink
feat: added error log for dio adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
jhomlala committed Jun 22, 2024
1 parent 06b5e18 commit fc5b275
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/alice_chopper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 1.0.4

* Create error log on exception (by Klemen Tusar https://github.com/techouse).
* Create error log on http exception (by Klemen Tusar https://github.com/techouse).
* Fixed HTTP error status (by Klemen Tusar https://github.com/techouse).
* Changed linter from very good analysis to flutter lints.
* General code base refactor.
Expand Down
1 change: 1 addition & 0 deletions packages/alice_dio/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Changed linter from very good analysis to flutter lints.
* General code base refactor.
* Create error log on http exception.

# 1.0.2

Expand Down
8 changes: 8 additions & 0 deletions packages/alice_dio/lib/alice_dio_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import 'package:alice/model/alice_http_call.dart';
import 'package:alice/model/alice_http_error.dart';
import 'package:alice/model/alice_http_request.dart';
import 'package:alice/model/alice_http_response.dart';
import 'package:alice/model/alice_log.dart';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';

class AliceDioAdapter extends InterceptorsWrapper with AliceAdapter {
/// Handles dio request and creates alice http call based on it
Expand Down Expand Up @@ -149,6 +151,12 @@ class AliceDioAdapter extends InterceptorsWrapper with AliceAdapter {
httpResponse,
error.response!.requestOptions.hashCode,
);
aliceCore.addLog(AliceLog(
message: error.toString(),
level: DiagnosticLevel.error,
error: error,
stackTrace: error.stackTrace
));
}
handler.next(error);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/alice_dio/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ environment:
dependencies:
alice: ^1.0.0-dev.4
dio: ^5.4.3+1
flutter:
sdk: flutter

dev_dependencies:
flutter_lints: ^4.0.0

0 comments on commit fc5b275

Please sign in to comment.