Fix error handling in various admin and inventory screens
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:
Nils-Johan Gynther
2026-05-04 22:25:56 +02:00
parent db02f6f0fb
commit 505c89c731
17 changed files with 85583 additions and 75920 deletions
+1 -1
View File
@@ -1 +1 @@
f8c96b9ba70d270e1df926aec2a1e154
6e2e38530c027a62d1a8a4b4204231db
+1 -1
View File
@@ -37,6 +37,6 @@ _flutter.buildConfig = {"engineRevision":"59aa584fdf100e6c78c785d8a5b565d1de4b48
_flutter.loader.load({
serviceWorkerSettings: {
serviceWorkerVersion: "1494425110" /* Flutter's service worker is deprecated and will be removed in a future Flutter release. */
serviceWorkerVersion: "3041144465" /* Flutter's service worker is deprecated and will be removed in a future Flutter release. */
}
});
+85555 -75892
View File
File diff suppressed because one or more lines are too long
@@ -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)),
);
}
}