Added more specific error messages

This commit was created in reaction to the new error messages:
606709ae58/src/api/acts/roomContent.ts
(outbag/server@3686c354c8)
This commit is contained in:
Jakob Meier 2023-03-31 21:59:27 +02:00
parent a40e3af3e5
commit 661cfe2f2c
No known key found for this signature in database
GPG key ID: 66BDC7E6A01A6152
2 changed files with 108 additions and 23 deletions

View file

@ -5,27 +5,77 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
*/ */
String errorAsString(Map<String, dynamic> json, AppLocalizations trans) { String errorAsString(Map<String, dynamic> json, AppLocalizations trans) {
switch (json['data']) { switch (json['data']) {
case 'closed':
return trans.errorServerClosed;
case 'bruteforce':
return trans.errorBruteforce;
case 'notfound': case 'notfound':
return trans.errorNotFound; return trans.errorNotFound;
case 'wrongstate': case 'wrongstate':
return trans.errorDataIncomplete; return trans.errorInvalidState;
case 'data': case 'data':
return trans.errorDataInvalid; return trans.errorInvalidData;
case 'roomAdmin':
case 'right': case 'right':
return trans.errorPermissions; return trans.errorServerPermissions;
case 'server': case 'server':
return trans.errorServer; 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': case 'auth':
return trans.errorAuth; return trans.errorAuth;
case 'ota': case 'signature':
return trans.errorInvalidOTA; return trans.errorInvalidSignature;
case 'existence': case 'token':
return trans.errorUsernameUnavailable; return trans.errorInvalidToken;
case 'config':
return trans.errorServerLimit;
} }
return trans.errorUnknown; return trans.errorUnknown;

View file

@ -121,16 +121,6 @@
"errorUnknown": "Unknown error", "errorUnknown": "Unknown error",
"errorServer":"Server 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", "themeLight": "Light",
"themeDark": "Dark", "themeDark": "Dark",
"themeSystem": "System", "themeSystem": "System",
@ -277,11 +267,56 @@
"errorPasswordsDontMatch": "New passwords do not match", "errorPasswordsDontMatch": "New passwords do not match",
"errorOldPasswordWrong": "Your old password is wrong", "errorOldPasswordWrong": "Your old password is wrong",
"newCategoryShort": "New",
"newCategoryLong": "Create a new category",
"yes": "Yes", "yes": "Yes",
"loading": "Loading", "loading": "Loading",
"dismiss": "Dismiss", "dismiss": "Dismiss",
"cancel": "Cancel", "cancel": "Cancel",
"ok": "OK", "ok": "OK",
"close": "Close", "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"
} }