Skip to content

Commit

Permalink
fix(error-interceptor): type-cast issue
Browse files Browse the repository at this point in the history
Signed-off-by: Taranjeet Singh <[email protected]>
  • Loading branch information
singhtaranjeet committed Aug 25, 2023
1 parent ef4b0e1 commit a671c7e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/src/exceptions/errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ class UnauthenticatedError extends DioException {
? response?.data
: 'Unauthenticated, Please try again';
}

UnauthenticatedError.fromDioError(DioError error)
: super(
requestOptions: error.requestOptions,
response: error.response,
type: error.type,
error: error,
);
}

class UnknownApiError extends DioException {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/interceptors/error_interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class ErrorInterceptor extends Interceptor {
if (error.type == DioExceptionType.badResponse) {
final code = error.response!.statusCode;
if (code == 401) {
final unauthenticatedError = error as UnauthenticatedError;
final unauthenticatedError = UnauthenticatedError.fromDioError(error);
// IF headers contains key [isAuthRequired]
// then not clearing auth data when 401 occurs
final isLoginApi = checkIsLoginApi(unauthenticatedError);
Expand Down

0 comments on commit a671c7e

Please sign in to comment.