From 661cfe2f2c1afb1dc17561fa781bedcf3902a539 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 31 Mar 2023 21:59:27 +0200 Subject: [PATCH] Added more specific error messages This commit was created in reaction to the new error messages: https://codeberg.org/outbag/server/src/commit/606709ae586e6764e6a4263f10f2ed99e7cb4702/src/api/acts/roomContent.ts (outbag/server@3686c354c867d3cb20e90ec919a3ae5335d5832b) --- lib/backend/errors.dart | 74 ++++++++++++++++++++++++++++++++++------- lib/l10n/app_en.arb | 57 +++++++++++++++++++++++++------ 2 files changed, 108 insertions(+), 23 deletions(-) diff --git a/lib/backend/errors.dart b/lib/backend/errors.dart index 2bd7b58..040408a 100644 --- a/lib/backend/errors.dart +++ b/lib/backend/errors.dart @@ -5,27 +5,77 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart'; */ String errorAsString(Map json, AppLocalizations trans) { switch (json['data']) { + case 'closed': + return trans.errorServerClosed; + case 'bruteforce': + return trans.errorBruteforce; case 'notfound': return trans.errorNotFound; case 'wrongstate': - return trans.errorDataIncomplete; + return trans.errorInvalidState; case 'data': - return trans.errorDataInvalid; - case 'roomAdmin': + return trans.errorInvalidData; case 'right': - return trans.errorPermissions; + return trans.errorServerPermissions; case 'server': return trans.errorServer; - case 'closed': - return trans.errorUnreachable; + + case 'recursion': + return trans.errorRemoteRecursion; + case 'remote': + return trans.errorRemote; + + case 'clientnotexists': + return trans.errorAccountDeletion; + case 'accountnotexists': + return trans.errorNoSuchAccount; + case 'accountexists': + return trans.errorUsernameTaken; + case 'roomexists': + return trans.errorRoomIdTaken; + case 'roomnotexists': + return trans.errorNoSuchRoom; + + case 'membernotexists': + return trans.errorNoSuchRoomMember; + case 'memberexists': + return trans.errorAlreadyInRoom; + case 'roomlimit': + return trans.errorReachedRoomLimit; + case 'roomuserlimit': + return trans.errorReachedRoomUserLimit; + case 'roomdatalimit': + return trans.errorReachedRoomDataLimit; + case 'notroomadmin': + return trans.errorRoomPermissions; + case 'notinroom': + return trans.errorNotRoomMember; + case 'owner': + return trans.errorRoomOwner; + + case 'catnotexists': + return trans.errorNoSuchCategory; + case 'prodnotexists': + return trans.errorNoSuchProduct; + case 'itemnotexists': + return trans.errorNoSuchItem; + case 'addcat': + return trans.errorCreatingCategory; + case 'addprod': + return trans.errorCreatingProduct; + case 'additem': + return trans.errorCreatingItem; + + case 'config': + return trans.errorServerConfig; + case 'ota': + return trans.errorOTA; case 'auth': return trans.errorAuth; - case 'ota': - return trans.errorInvalidOTA; - case 'existence': - return trans.errorUsernameUnavailable; - case 'config': - return trans.errorServerLimit; + case 'signature': + return trans.errorInvalidSignature; + case 'token': + return trans.errorInvalidToken; } return trans.errorUnknown; diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 0ba55cc..ac5ba39 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -121,16 +121,6 @@ "errorUnknown": "Unknown error", "errorServer":"Server error", - "errorNotFound":"Not found", - "errorDataIncomplete":"Missing data", - "errorDataInvalid":"Invalid data", - "errorPermissions":"You are not allowed to perform this action", - "errorUnreachable":"Server cannot be reached", - "errorAuth":"Username or password wrong", - "errorInvalidOTA":"Invalid OTA", - "errorUsernameUnavailable":"A user with that name already exists", - "errorServerLimit":"Server reached user limit", - "themeLight": "Light", "themeDark": "Dark", "themeSystem": "System", @@ -277,11 +267,56 @@ "errorPasswordsDontMatch": "New passwords do not match", "errorOldPasswordWrong": "Your old password is wrong", + "newCategoryShort": "New", + "newCategoryLong": "Create a new category", + "yes": "Yes", "loading": "Loading", "dismiss": "Dismiss", "cancel": "Cancel", "ok": "OK", "close": "Close", - "update": "Update" + "update": "Update", + + "errorServerClosed": "Server is offline", + "errorBruteforce": "Too many requests", + "errorNotFound": "Ressource not found", + "errorInvalidState": "Missing data", + "errorInvalidData": "Invalid data", + "errorServerPermissions": "You are not allowed to perform this action", + "errorRemoteRecursion": "Unable to forward request to remote", + + "errorRemote": "Unable to process remote request", + + "errorAccountDeletion": "Your account no longer exists", + + "errorNoSuchAccount": "Account does not exist", + "errorUsernameTaken": "Already with that username already exists", + "errorNoSuchRoom": "Room does not exist", + "errorRoomIdTaken": "Room with that ID already exists", + + "errorNoSuchRoomMember": "There is no Member with that ID", + "errorAlreadyInRoom": "The user is already a member of this room", + "errorReachedRoomLimit": "You are not allowed to create more rooms", + "errorReachedRoomUserLimit": "Cannot join room. User limit exceeded", + "errorReachedRoomDataLimit": "Reached room storage limit", + "errorNotRoomMember": "You are not a member of this room", + "errorRoomOwner": "The room owner (you) is not allowed to perform this action", + "errorRoomPermissions": "You are not allowed to perform this action", + + "errorNoSuchCategory": "Category does not exist", + "errorNoSuchProduct": "Product does not exist", + "errorNoSuchItem": "Item does not exist", + "errorCreatingCategory": "Unable to create Category", + "errorCreatingProduct": "Unable to create Product", + "errorCreatingItem": "Unable to create Item", + + "errorServerConfig": "Cannot join server. User limit exceeded", + "errorOTA": "Invalid OTA", + "errorAuth": "Username or password wrong", + "errorInvalidSignature": "Unable to verify signature", + "errorInvalidToken": "Invalid Token", + + "errorServerDoesntExist": "Server does not exist", + "errorInvalidServerToken": "Server token invalid" }