2023-03-29 15:14:27 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
|
2023-03-17 21:06:23 +01:00
|
|
|
/*
|
2023-03-22 21:17:03 +01:00
|
|
|
* Tool to automatically generate english text from error
|
|
|
|
*/
|
2023-03-29 15:14:27 +02:00
|
|
|
String errorAsString(Map<String, dynamic> json, AppLocalizations trans) {
|
2023-03-22 21:17:03 +01:00
|
|
|
switch (json['data']) {
|
2023-03-31 21:59:27 +02:00
|
|
|
case 'closed':
|
|
|
|
return trans.errorServerClosed;
|
|
|
|
case 'bruteforce':
|
|
|
|
return trans.errorBruteforce;
|
2023-03-22 21:17:03 +01:00
|
|
|
case 'notfound':
|
2023-03-29 15:14:27 +02:00
|
|
|
return trans.errorNotFound;
|
2023-03-22 21:17:03 +01:00
|
|
|
case 'wrongstate':
|
2023-03-31 21:59:27 +02:00
|
|
|
return trans.errorInvalidState;
|
2023-03-22 21:17:03 +01:00
|
|
|
case 'data':
|
2023-03-31 21:59:27 +02:00
|
|
|
return trans.errorInvalidData;
|
2023-03-22 21:17:03 +01:00
|
|
|
case 'right':
|
2023-03-31 21:59:27 +02:00
|
|
|
return trans.errorServerPermissions;
|
2023-03-22 21:17:03 +01:00
|
|
|
case 'server':
|
2023-03-29 15:14:27 +02:00
|
|
|
return trans.errorServer;
|
2023-03-31 21:59:27 +02:00
|
|
|
|
|
|
|
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;
|
2023-03-22 21:17:03 +01:00
|
|
|
case 'auth':
|
2023-03-29 15:14:27 +02:00
|
|
|
return trans.errorAuth;
|
2023-03-31 21:59:27 +02:00
|
|
|
case 'signature':
|
|
|
|
return trans.errorInvalidSignature;
|
|
|
|
case 'token':
|
|
|
|
return trans.errorInvalidToken;
|
2023-03-22 21:17:03 +01:00
|
|
|
}
|
2023-03-17 21:06:23 +01:00
|
|
|
|
2023-03-29 15:14:27 +02:00
|
|
|
return trans.errorUnknown;
|
2023-03-17 21:06:23 +01:00
|
|
|
}
|