mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
Refactor error handling in AuthCubit and ServerFailure
Update error handling in AuthCubit to use toString() method and mdified handling of badResponse in ServerFailure class.
This commit is contained in:
@ -66,7 +66,7 @@ class AuthCubit extends Cubit<AuthState> {
|
|||||||
emit(AuthError('Something went wrong'));
|
emit(AuthError('Something went wrong'));
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
emit(AuthError(ServerFailure.fromDioError(e).errMessage));
|
emit(AuthError(ServerFailure.fromDioError(e).toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ class ServerFailure extends Failure {
|
|||||||
return ServerFailure("Bad certificate!");
|
return ServerFailure("Bad certificate!");
|
||||||
|
|
||||||
case DioExceptionType.badResponse:
|
case DioExceptionType.badResponse:
|
||||||
return ServerFailure.fromResponse(
|
return ServerFailure.fromResponse(dioError.response!.statusCode!,
|
||||||
dioError.response!.statusCode!, dioError.response!.data);
|
dioError.response!.data!["message"]);
|
||||||
case DioExceptionType.cancel:
|
case DioExceptionType.cancel:
|
||||||
return ServerFailure("The request to ApiServer was canceled");
|
return ServerFailure("The request to ApiServer was canceled");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user