mirror of
https://github.com/inventree/inventree-app.git
synced 2025-07-01 11:20:41 +00:00
Improve invalid response code messages
This commit is contained in:
2
lib/l10n
2
lib/l10n
Submodule lib/l10n updated: 05207b7e5b...654b12d727
@ -130,9 +130,37 @@ Future<void> showServerError(String title, String description) async {
|
|||||||
|
|
||||||
Future<void> showStatusCodeError(int status, {int expected = 200}) async {
|
Future<void> showStatusCodeError(int status, {int expected = 200}) async {
|
||||||
|
|
||||||
|
BuildContext ctx = OneContext().context;
|
||||||
|
|
||||||
|
String msg = I18N.of(ctx).responseInvalid;
|
||||||
|
String extra = "Server responded with status code ${status}";
|
||||||
|
|
||||||
|
switch (status) {
|
||||||
|
case 400:
|
||||||
|
msg = I18N.of(ctx).response400;
|
||||||
|
break;
|
||||||
|
case 401:
|
||||||
|
msg = I18N.of(ctx).response401;
|
||||||
|
break;
|
||||||
|
case 403:
|
||||||
|
msg = I18N.of(ctx).response403;
|
||||||
|
break;
|
||||||
|
case 404:
|
||||||
|
msg = I18N.of(ctx).response404;
|
||||||
|
break;
|
||||||
|
case 405:
|
||||||
|
msg = I18N.of(ctx).response405;
|
||||||
|
break;
|
||||||
|
case 429:
|
||||||
|
msg = I18N.of(ctx).response429;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
showServerError(
|
showServerError(
|
||||||
I18N.of(OneContext().context).responseInvalid,
|
msg,
|
||||||
"Server responded with status code ${status}"
|
extra,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,10 +90,15 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
|
|
||||||
final bool result = await part.update(context, values: values);
|
final bool result = await part.update(context, values: values);
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
showSnackIcon("Part edited", success: true);
|
||||||
|
}
|
||||||
|
/*
|
||||||
showSnackIcon(
|
showSnackIcon(
|
||||||
result ? "Part edited" : "Part editing failed",
|
result ? "Part edited" : "Part editing failed",
|
||||||
success: result
|
success: result
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user