|
@@ -1,6 +1,7 @@
|
|
|
import 'dart:math';
|
|
|
|
|
|
import 'package:confetti/confetti.dart';
|
|
|
+import "package:dio/dio.dart";
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:photos/core/constants.dart';
|
|
|
import "package:photos/models/search/button_result.dart";
|
|
@@ -38,6 +39,35 @@ Future<ButtonResult?> showErrorDialog(
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+Future<ButtonResult?> showErrorDialogForException({
|
|
|
+ required BuildContext context,
|
|
|
+ required Exception exception,
|
|
|
+ bool isDismissible = true,
|
|
|
+}) async {
|
|
|
+ String errorMessage =
|
|
|
+ "It looks like something went wrong. Please retry after some time. If the error persists, please contact our support team.";
|
|
|
+ if (exception is DioError &&
|
|
|
+ exception.response != null &&
|
|
|
+ exception.response!.data["code"] != null) {
|
|
|
+ errorMessage = "It looks like something went wrong. \n\nReason: " +
|
|
|
+ exception.response!.data["code"];
|
|
|
+ }
|
|
|
+ return showDialogWidget(
|
|
|
+ context: context,
|
|
|
+ title: "Error",
|
|
|
+ icon: Icons.error_outline_outlined,
|
|
|
+ body: errorMessage,
|
|
|
+ isDismissible: isDismissible,
|
|
|
+ buttons: const [
|
|
|
+ ButtonWidget(
|
|
|
+ buttonType: ButtonType.secondary,
|
|
|
+ labelText: "OK",
|
|
|
+ isInAlert: true,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
///Will return null if dismissed by tapping outside
|
|
|
Future<ButtonResult?> showGenericErrorDialog({
|
|
|
required BuildContext context,
|