From fd1c104e6a02757c0025ee0e44349d288cd9614b Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 17 Mar 2023 21:06:23 +0100 Subject: [PATCH] Ported error_as_text from https://codeberg.org/outbag/app/src/branch/develop/deps/outbag-core/src/tools.js --- lib/backend/errors.dart | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lib/backend/errors.dart 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"; +}