Fix error handling in various admin and inventory screens
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
- Updated error handling in AdminAliasesPanel, AdminDatabasePanel, AdminPendingProductsPanel, and AdminProductsPanel to ensure consistent snackbar display without extra parentheses. - Refined error handling in ConsumeInventoryScreen, CreateInventoryScreen, InventoryDetailScreen, InventoryEditScreen, and SwipeableInventoryTile to maintain consistent snackbar formatting. - Improved error handling in MealPlanScreen, PantryScreen, ProfileScreen, and RecipeDetailScreen to ensure proper user feedback on errors.
This commit is contained in:
@@ -94,7 +94,7 @@ class _AdminAliasesPanelState extends ConsumerState<AdminAliasesPanel> {
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
} finally {
|
||||
if (mounted) setState(() => _isSaving = false);
|
||||
@@ -133,7 +133,7 @@ class _AdminAliasesPanelState extends ConsumerState<AdminAliasesPanel> {
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class _AdminDatabasePanelState extends ConsumerState<AdminDatabasePanel> {
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
} finally {
|
||||
if (mounted) setState(() => _isRefreshingCategories = false);
|
||||
|
||||
@@ -57,7 +57,7 @@ class _AdminPendingProductsPanelState
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
} finally {
|
||||
if (mounted) setState(() => _processingId = null);
|
||||
|
||||
@@ -132,7 +132,7 @@ class _AdminProductsPanelState extends ConsumerState<AdminProductsPanel> {
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
} finally {
|
||||
if (mounted) setState(() => _isApplying = false);
|
||||
@@ -181,7 +181,7 @@ class _AdminProductsPanelState extends ConsumerState<AdminProductsPanel> {
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
} finally {
|
||||
if (mounted) setState(() => _isAiRunning = false);
|
||||
@@ -321,7 +321,7 @@ class _AdminProductsPanelState extends ConsumerState<AdminProductsPanel> {
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -358,7 +358,7 @@ class _AdminProductsPanelState extends ConsumerState<AdminProductsPanel> {
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -380,7 +380,7 @@ class _AdminProductsPanelState extends ConsumerState<AdminProductsPanel> {
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
} finally {
|
||||
if (mounted) setState(() => _isApplying = false);
|
||||
@@ -399,7 +399,7 @@ class _AdminProductsPanelState extends ConsumerState<AdminProductsPanel> {
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -435,7 +435,7 @@ class _AdminProductsPanelState extends ConsumerState<AdminProductsPanel> {
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
setState(() => _rowCategorySaving.remove(product.id));
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class _ConsumeInventoryScreenState
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))));
|
||||
.showSnackBar(buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)));
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _saving = false);
|
||||
|
||||
@@ -76,7 +76,7 @@ class _CreateInventoryScreenState
|
||||
if (mounted) setState(() => _loadingProducts = false);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ class _CreateInventoryScreenState
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))));
|
||||
.showSnackBar(buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)));
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _saving = false);
|
||||
|
||||
@@ -122,7 +122,7 @@ class _DeleteButton extends ConsumerWidget {
|
||||
} catch (e) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ class _InventoryEditScreenState extends ConsumerState<InventoryEditScreen> {
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))));
|
||||
.showSnackBar(buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)));
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _saving = false);
|
||||
|
||||
@@ -122,7 +122,7 @@ class _SwipeableInventoryTileState
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
} finally {
|
||||
if (mounted) setState(() => _acting = false);
|
||||
@@ -372,7 +372,7 @@ class _DeleteButton extends ConsumerWidget {
|
||||
ref.invalidate(inventoryProvider);
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class _MealPlanScreenState extends ConsumerState<MealPlanScreen> {
|
||||
} catch (error) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(error, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(error, context)),
|
||||
);
|
||||
} finally {
|
||||
if (mounted) {
|
||||
|
||||
@@ -166,7 +166,7 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
|
||||
_logger.severe('Failed to add item to inventory: $error');
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(error, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(error, context)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -185,7 +185,7 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
|
||||
_logger.severe('Failed to add pantry item: $error');
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(error, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(error, context)),
|
||||
);
|
||||
} finally {
|
||||
if (mounted) setState(() => _isSubmitting = false);
|
||||
@@ -221,7 +221,7 @@ class _PantryScreenState extends ConsumerState<PantryScreen> {
|
||||
_logger.severe('Failed to remove pantry item: $error');
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(error, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(error, context)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
} finally {
|
||||
if (mounted) setState(() => _isSaving = false);
|
||||
|
||||
@@ -193,7 +193,7 @@ class RecipeDetailScreen extends ConsumerWidget {
|
||||
} on ApiException catch (e) {
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -281,7 +281,7 @@ class RecipeDetailScreen extends ConsumerWidget {
|
||||
} on ApiException catch (e) {
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -353,7 +353,7 @@ class _DeleteButton extends ConsumerWidget {
|
||||
} on ApiException catch (e) {
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
|
||||
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user