Skip to content

Commit

Permalink
Merge pull request #119 from ahmtydn/fix/token-refresh-error-handling
Browse files Browse the repository at this point in the history
Fix Issue with Retrying Failed Request After Successful Token Refresh
  • Loading branch information
VB10 authored Nov 27, 2024
2 parents 61b0064 + c1b8878 commit 0053c25
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 0053c25

Please sign in to comment.