Skip to content

Commit

Permalink
LA-1238 removed hardcoded error code value
Browse files Browse the repository at this point in the history
  • Loading branch information
KhaledNjim authored and hoangdat committed Apr 5, 2024
1 parent 279547c commit 9eefacc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import 'package:data/data.dart';
import 'package:data/src/network/model/response/user_response.dart';
import 'package:dio/dio.dart';
import 'package:domain/domain.dart';
import 'package:flutter/foundation.dart';

class AuthenticationDataSourceImpl implements AuthenticationDataSource {

Expand Down Expand Up @@ -106,7 +105,7 @@ class AuthenticationDataSourceImpl implements AuthenticationDataSource {
_remoteExceptionThrower.throwRemoteException(error, handler: (DioError error) {
final errorCode = error.response?.headers.value(Constant.linShareAuthErrorCode) ?? '1';
final authErrorCode = LinShareErrorCode(int.tryParse(errorCode) ?? 1);
if(authErrorCode.value==1000){
if(authErrorCode.canNotGetJwt()){
throw NotAuthorizedUser();
}
throw UnknownError(error.response?.statusMessage!);
Expand Down
3 changes: 2 additions & 1 deletion domain/lib/src/errorcode/business_error_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class BusinessErrorCode {
static final workspaceLimit = LinShareErrorCode(50016);
static final nestedWorkgroupLimit = LinShareErrorCode(55508);
static final uploadRequestLimitReach = LinShareErrorCode(31416);
static final noValidTokenFound = [LinShareErrorCode(1005)];
static final noValidPermanentTokenFound = [LinShareErrorCode(1005)];
static final noValidJwt = [LinShareErrorCode(1000)];

}
9 changes: 7 additions & 2 deletions domain/lib/src/model/linshare_error_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ extension LinShareErrorCodeExtension on LinShareErrorCode {

bool isAuthenticateErrorUserLocked() =>
BusinessErrorCode.authenErrorUserLocked.contains(this);

bool isTokenDeleted()=>
BusinessErrorCode.noValidTokenFound.contains(this);
}
BusinessErrorCode.noValidPermanentTokenFound.contains(this);

bool canNotGetJwt()=>
BusinessErrorCode.noValidJwt.contains(this);
}

0 comments on commit 9eefacc

Please sign in to comment.