docs(#14): note back config/setup + frontend parsing erreurs
- docs/14_NOTE-BACKEND-CONFIG-SETUP.md : modifs à faire côté back (UUID system) - configuration_service : parsing défensif des réponses d'erreur (évite JSNull) Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -106,8 +106,9 @@ class ConfigurationService {
|
||||
body: jsonEncode(body),
|
||||
);
|
||||
if (response.statusCode != 200) {
|
||||
final err = jsonDecode(response.body) as Map;
|
||||
throw Exception(err['message'] ?? 'Erreur lors de la sauvegarde');
|
||||
final err = jsonDecode(response.body) as Map<String, dynamic>?;
|
||||
final msg = err != null ? (err['message'] as String? ?? err['error'] as String?) : null;
|
||||
throw Exception(msg ?? 'Erreur lors de la sauvegarde');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,11 +119,12 @@ class ConfigurationService {
|
||||
headers: await _headers(),
|
||||
body: jsonEncode({'testEmail': testEmail}),
|
||||
);
|
||||
final data = jsonDecode(response.body) as Map;
|
||||
if (response.statusCode == 200 && data['success'] == true) {
|
||||
return data['message'] as String? ?? 'Test SMTP réussi.';
|
||||
final data = jsonDecode(response.body) as Map<String, dynamic>?;
|
||||
if (response.statusCode == 200 && (data?['success'] == true)) {
|
||||
return data!['message'] as String? ?? 'Test SMTP réussi.';
|
||||
}
|
||||
throw Exception(data['error'] ?? data['message'] ?? 'Échec du test SMTP');
|
||||
final msg = data != null ? (data['error'] as String? ?? data['message'] as String?) : null;
|
||||
throw Exception(msg ?? 'Échec du test SMTP');
|
||||
}
|
||||
|
||||
/// POST /api/v1/configuration/setup/complete (après première config)
|
||||
@@ -132,8 +134,9 @@ class ConfigurationService {
|
||||
headers: await _headers(),
|
||||
);
|
||||
if (response.statusCode != 200) {
|
||||
final err = jsonDecode(response.body) as Map;
|
||||
throw Exception(err['message'] ?? 'Erreur finalisation configuration');
|
||||
final err = jsonDecode(response.body) as Map<String, dynamic>?;
|
||||
final msg = err != null ? (err['message'] as String? ?? err['error'] as String?) : null;
|
||||
throw Exception(msg ?? 'Erreur finalisation configuration');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user