Skip to content

Commit

Permalink
Fix error handling after token refresh to manage new errors correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmtydn committed Sep 28, 2024
1 parent 7922193 commit c1b8878
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ packages:
path: ".."
relative: true
source: path
version: "4.1.0"
version: "5.0.1"
vm_service:
dependency: transitive
description:
Expand Down
9 changes: 8 additions & 1 deletion lib/src/mixin/network_manager_error_interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,17 @@ mixin NetworkManagerErrorInterceptor {
}
// Call onResponseParse callback and return response
return handler.resolve(parameters.onResponseParse!(response));
} catch (_) {
} catch (err) {
/// cancel request & call onRefreshFail callback and unlock
error.requestOptions.cancelToken?.cancel();
parameters.onRefreshFail?.call();

/// If error is DioException, then return error
if (err is DioException) {
return handler.next(err);
}

/// If error is not DioException, then return error
return handler.next(exception);
}
},
Expand Down

0 comments on commit c1b8878

Please sign in to comment.