improving error handling
This commit is contained in:
@@ -170,13 +170,28 @@ class _PayScreenState extends State<PayScreen> with TickerProviderStateMixin {
|
||||
final apiResponse = await controller.doTransaction();
|
||||
|
||||
if (!apiResponse.isSuccess) {
|
||||
if (context.mounted) {
|
||||
AppSnackBar.showError(
|
||||
context,
|
||||
String errorMessage =
|
||||
controller.model.errorMessage ??
|
||||
apiResponse.error ??
|
||||
"Transaction failed",
|
||||
);
|
||||
apiResponse.error ??
|
||||
"Transaction failed";
|
||||
if (context.mounted) {
|
||||
if (errorMessage.contains(
|
||||
"We can't process that transaction right now",
|
||||
)) {
|
||||
AppSnackBar.show(
|
||||
context,
|
||||
errorMessage,
|
||||
action: SnackBarAction(
|
||||
label: 'Check uptime',
|
||||
textColor: Colors.yellow, // Optional custom styling
|
||||
onPressed: () {
|
||||
context.push('/uptime');
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
AppSnackBar.showError(context, errorMessage);
|
||||
}
|
||||
}
|
||||
} else if (controller.model.status == "SUCCESS" && context.mounted) {
|
||||
context.push('/confirm');
|
||||
|
||||
Reference in New Issue
Block a user