From 529510bc5c56dfcd56d7de5a8ac0511967af19ef Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 2 Oct 2021 22:33:59 +1000 Subject: [PATCH] Display HTTP error codes on form errors --- lib/api_form.dart | 37 +++++++++++++++++++++++++++++++++---- lib/l10n | 2 +- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/lib/api_form.dart b/lib/api_form.dart index 50e44d54..35d82dbe 100644 --- a/lib/api_form.dart +++ b/lib/api_form.dart @@ -885,7 +885,7 @@ class _APIFormWidgetState extends State { case 400: // Form submission / validation error showSnackIcon( - L10().error, + L10().formError, success: false ); @@ -894,13 +894,42 @@ class _APIFormWidgetState extends State { field.data["errors"] = response.data[field.name]; } break; - case 405: + case 401: showSnackIcon( - L10().response405, + "401: " + L10().response401, + success: false + ); + break; + case 403: + showSnackIcon( + "403: " + L10().response403, + success: false, + ); + break; + case 404: + showSnackIcon( + "404: " + L10().response404, + success: false, + ); + break; + case 405: + showSnackIcon( + "405: " + L10().response405, + success: false, + ); + break; + case 500: + showSnackIcon( + "500: " + L10().response500, + success: false, + ); + break; + default: + showSnackIcon( + "${response.statusCode}: " + L10().responseInvalid, success: false, ); break; - // TODO: Other status codes? } setState(() { diff --git a/lib/l10n b/lib/l10n index bdaf7a51..ef5ca26e 160000 --- a/lib/l10n +++ b/lib/l10n @@ -1 +1 @@ -Subproject commit bdaf7a516cc40caf6ee1110fea6af073a61d7829 +Subproject commit ef5ca26effc8b203a0f49c0fd50afdc8ef2cc3aa