revamp new trip flow
This commit is contained in:
@@ -29,11 +29,10 @@ Dio dio = Dio(
|
||||
|
||||
fetchTrip(
|
||||
Trip trip,
|
||||
Future<UserPreferences> preferences,
|
||||
UserPreferences preferences,
|
||||
) async {
|
||||
UserPreferences prefs = await preferences;
|
||||
Map<String, dynamic> data = {
|
||||
"preferences": prefs.toJson(),
|
||||
"preferences": preferences.toJson(),
|
||||
"start": trip.landmarks!.first.location,
|
||||
};
|
||||
String dataString = jsonEncode(data);
|
||||
@@ -47,11 +46,16 @@ fetchTrip(
|
||||
// handle errors
|
||||
if (response.statusCode != 200) {
|
||||
trip.updateUUID("error");
|
||||
if (response.data["detail"] != null) {
|
||||
trip.updateError(response.data["detail"]);
|
||||
log(response.data["detail"]);
|
||||
// throw Exception(response.data["detail"]);
|
||||
String errorDetail;
|
||||
if (response.data.runtimeType == String) {
|
||||
errorDetail = response.data;
|
||||
} else {
|
||||
errorDetail = response.data["detail"] ?? "Unknown error";
|
||||
}
|
||||
trip.updateError(errorDetail);
|
||||
log(errorDetail);
|
||||
// Actualy no need to throw an exception, we can just log the error and let the user retry
|
||||
// throw Exception(errorDetail);
|
||||
} else {
|
||||
Map<String, dynamic> json = response.data;
|
||||
|
||||
|
Reference in New Issue
Block a user