Skip to content

Commit

Permalink
feat: Better error message for search screen (#5298)
Browse files Browse the repository at this point in the history
* Better error message

* Reuse the previous format
  • Loading branch information
g123k authored May 28, 2024
1 parent b25a034 commit 4b6ed1e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
10 changes: 10 additions & 0 deletions packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,16 @@
"@could_not_refresh": {
"description": "The product data couldn't be refreshed"
},
"product_internet_error_modal_title": "An error has occurred!",
"product_internet_error_modal_message": "We are unable to fetch information about this product due to a network error. Please check your internet connection and try again.\n\nInternal error:\n{error}",
"@product_internet_error_modal_message": {
"placeholders": {
"error": {
"type": "String",
"description": "The error message"
}
}
},
"product_internet_error": "Impossible to fetch information about this product due to a network error.",
"cached_results_from": "Show results from:",
"@cached_results_from": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,18 @@ class ProductDialogHelper {

void _openErrorMessage(final String message) => showDialog<void>(
context: context,
builder: (BuildContext context) => SmoothAlertDialog(
body: getErrorMessage(message),
positiveAction: SmoothActionButton(
text: AppLocalizations.of(context).close,
onPressed: () => Navigator.pop(context),
),
),
builder: (BuildContext context) {
final AppLocalizations localizations = AppLocalizations.of(context);

return SmoothAlertDialog(
title: localizations.product_internet_error_modal_title,
body: getErrorMessage(message),
positiveAction: SmoothActionButton(
text: localizations.close,
onPressed: () => Navigator.pop(context),
),
);
},
);

/// Opens an error dialog; to be used only if the status is not ok.
Expand All @@ -185,7 +190,10 @@ class ProductDialogHelper {
case FetchedProductStatus.userCancelled:
return;
case FetchedProductStatus.internetError:
_openErrorMessage(appLocalizations.product_internet_error);
_openErrorMessage(
appLocalizations.product_internet_error_modal_message(
fetchedProduct.exceptionString ?? '-'),
);
return;
case FetchedProductStatus.internetNotFound:
_openProductNotFoundDialog();
Expand Down

0 comments on commit 4b6ed1e

Please sign in to comment.