refactor: Remove generic try-catch blocks and add explicit API error handling in activity places service.
All checks were successful
Deploy Flutter to Firebase (Mac) / deploy-android (push) Successful in 3m41s
All checks were successful
Deploy Flutter to Firebase (Mac) / deploy-android (push) Successful in 3m41s
This commit is contained in:
@@ -174,7 +174,11 @@ class ActivityBloc extends Bloc<ActivityEvent, ActivityState> {
|
||||
'Erreur recherche activités: $e',
|
||||
stackTrace,
|
||||
);
|
||||
emit(const ActivityError('Impossible de rechercher les activités'));
|
||||
// Extraire le message d'erreur si disponible
|
||||
final errorMessage = e.toString().replaceAll('Exception: ', '');
|
||||
emit(
|
||||
ActivityError('Impossible de rechercher les activités: $errorMessage'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ class ActivityPlacesService {
|
||||
int maxResults = 20,
|
||||
int offset = 0,
|
||||
}) async {
|
||||
try {
|
||||
LoggerService.info(
|
||||
'ActivityPlacesService: Recherche d\'activités pour: $destination (max: $maxResults, offset: $offset)',
|
||||
);
|
||||
@@ -107,13 +106,6 @@ class ActivityPlacesService {
|
||||
);
|
||||
|
||||
return paginatedResults;
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur lors de la recherche: $e',
|
||||
);
|
||||
_errorService.logError('activity_places_service', e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/// Géocode une destination pour obtenir les coordonnées
|
||||
@@ -191,7 +183,6 @@ class ActivityPlacesService {
|
||||
String tripId,
|
||||
int radius,
|
||||
) async {
|
||||
try {
|
||||
final url =
|
||||
'https://maps.googleapis.com/maps/api/place/nearbysearch/json'
|
||||
'?location=$lat,$lng'
|
||||
@@ -226,15 +217,18 @@ class ActivityPlacesService {
|
||||
}
|
||||
|
||||
return activities;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (data['status'] == 'ZERO_RESULTS') {
|
||||
return [];
|
||||
} catch (e) {
|
||||
} else {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur recherche par catégorie: $e',
|
||||
'ActivityPlacesService: Erreur API Places: ${data['status']} - ${data['error_message']}',
|
||||
);
|
||||
return [];
|
||||
throw Exception(
|
||||
'API Places Error: ${data['status']} - ${data['error_message']}',
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw Exception('Erreur HTTP ${response.statusCode}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,7 +351,6 @@ class ActivityPlacesService {
|
||||
required String tripId,
|
||||
int radius = 5000,
|
||||
}) async {
|
||||
try {
|
||||
LoggerService.info(
|
||||
'ActivityPlacesService: Recherche textuelle: $query à $destination',
|
||||
);
|
||||
@@ -404,15 +397,16 @@ class ActivityPlacesService {
|
||||
}
|
||||
|
||||
return activities;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (data['status'] == 'ZERO_RESULTS') {
|
||||
return [];
|
||||
} catch (e) {
|
||||
} else {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur recherche textuelle: $e',
|
||||
'ActivityPlacesService: Erreur API Places Text Search: ${data['status']}',
|
||||
);
|
||||
return [];
|
||||
throw Exception('API Error: ${data['status']}');
|
||||
}
|
||||
} else {
|
||||
throw Exception('Erreur HTTP ${response.statusCode}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,7 +517,6 @@ class ActivityPlacesService {
|
||||
int pageSize,
|
||||
String? nextPageToken,
|
||||
) async {
|
||||
try {
|
||||
String url =
|
||||
'https://maps.googleapis.com/maps/api/place/nearbysearch/json'
|
||||
'?location=$lat,$lng'
|
||||
@@ -570,23 +563,17 @@ class ActivityPlacesService {
|
||||
'nextPageToken': data['next_page_token'],
|
||||
'hasMoreData': data['next_page_token'] != null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
'activities': <Activity>[],
|
||||
'nextPageToken': null,
|
||||
'hasMoreData': false,
|
||||
};
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur recherche catégorie paginée: $e',
|
||||
);
|
||||
} else if (data['status'] == 'ZERO_RESULTS') {
|
||||
return {
|
||||
'activities': <Activity>[],
|
||||
'nextPageToken': null,
|
||||
'hasMoreData': false,
|
||||
};
|
||||
} else {
|
||||
throw Exception('API Error: ${data['status']}');
|
||||
}
|
||||
} else {
|
||||
throw Exception('Erreur HTTP ${response.statusCode}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,7 +586,6 @@ class ActivityPlacesService {
|
||||
int pageSize,
|
||||
String? nextPageToken,
|
||||
) async {
|
||||
try {
|
||||
// Pour toutes les catégories, on utilise une recherche plus générale
|
||||
String url =
|
||||
'https://maps.googleapis.com/maps/api/place/nearbysearch/json'
|
||||
@@ -651,23 +637,17 @@ class ActivityPlacesService {
|
||||
'nextPageToken': data['next_page_token'],
|
||||
'hasMoreData': data['next_page_token'] != null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
'activities': <Activity>[],
|
||||
'nextPageToken': null,
|
||||
'hasMoreData': false,
|
||||
};
|
||||
} catch (e) {
|
||||
LoggerService.error(
|
||||
'ActivityPlacesService: Erreur recherche toutes catégories paginée: $e',
|
||||
);
|
||||
} else if (data['status'] == 'ZERO_RESULTS') {
|
||||
return {
|
||||
'activities': <Activity>[],
|
||||
'nextPageToken': null,
|
||||
'hasMoreData': false,
|
||||
};
|
||||
} else {
|
||||
throw Exception('API Error: ${data['status']}');
|
||||
}
|
||||
} else {
|
||||
throw Exception('Erreur HTTP ${response.statusCode}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.3+1
|
||||
version: 2025.12.1+1
|
||||
|
||||
environment:
|
||||
sdk: ^3.9.2
|
||||
|
||||
Reference in New Issue
Block a user