refactoring
This commit is contained in:
@@ -33,6 +33,7 @@ class NetworkRepository {
|
||||
final data = _parseListResponse(response.data);
|
||||
return data.map((json) => _memberFromJson(json as Map<String, dynamic>)).toList();
|
||||
} on DioException catch (e) {
|
||||
if (e.type == DioExceptionType.cancel) rethrow;
|
||||
if (e.response?.statusCode == 400) return [];
|
||||
rethrow;
|
||||
}
|
||||
@@ -49,6 +50,7 @@ class NetworkRepository {
|
||||
final data = _parseListResponse(response.data);
|
||||
return data.map((json) => _organisationFromJson(json as Map<String, dynamic>)).toList();
|
||||
} on DioException catch (e) {
|
||||
if (e.type == DioExceptionType.cancel) rethrow;
|
||||
if (e.response?.statusCode == 400) return [];
|
||||
rethrow;
|
||||
}
|
||||
@@ -83,6 +85,7 @@ class NetworkRepository {
|
||||
if (data is! List) return [];
|
||||
return data.map((e) => e.toString()).toList();
|
||||
} on DioException catch (e) {
|
||||
if (e.type == DioExceptionType.cancel) rethrow;
|
||||
if (e.response?.statusCode == 401 || e.response?.statusCode == 403) return [];
|
||||
AppLogger.error('NetworkRepository: getFollowedIds échoué', error: e);
|
||||
rethrow;
|
||||
@@ -98,6 +101,7 @@ class NetworkRepository {
|
||||
}
|
||||
return false;
|
||||
} on DioException catch (e, st) {
|
||||
if (e.type == DioExceptionType.cancel) rethrow;
|
||||
AppLogger.error('NetworkRepository: follow échoué', error: e, stackTrace: st);
|
||||
rethrow;
|
||||
}
|
||||
@@ -112,6 +116,7 @@ class NetworkRepository {
|
||||
}
|
||||
return false;
|
||||
} on DioException catch (e, st) {
|
||||
if (e.type == DioExceptionType.cancel) rethrow;
|
||||
AppLogger.error('NetworkRepository: unfollow échoué', error: e, stackTrace: st);
|
||||
rethrow;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user