diff --git a/lib/backend/errors.dart b/lib/backend/errors.dart new file mode 100644 index 0000000..bcdb90e --- /dev/null +++ b/lib/backend/errors.dart @@ -0,0 +1,29 @@ +/* + * Tool to automatically generate english text from error + */ + String errorAsString(Map json) { + switch (json['data']) { + case 'notfound': + return 'Endpoint not found'; + case 'wrongstate': + return 'Missing data'; + case 'data': + return 'Invalid data'; + case 'right': + return 'You are not allowed to perform this action'; + case 'server': + return 'Server error'; + case 'closed': + return 'Server cannot be reached'; + case 'auth': + return 'Username or password wrong'; + case 'ota': + return 'Invalid OTA'; + case 'existence': + return 'Username unavailable'; + case 'config': + return 'Server reached user limit'; + } + + return "Unknown Error"; +}