Ported error_as_text from https://codeberg.org/outbag/app/src/branch/develop/deps/outbag-core/src/tools.js
This commit is contained in:
parent
fd2e21c328
commit
fd1c104e6a
1 changed files with 29 additions and 0 deletions
29
lib/backend/errors.dart
Normal file
29
lib/backend/errors.dart
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Tool to automatically generate english text from error
|
||||
*/
|
||||
String errorAsString(Map<String, dynamic> 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";
|
||||
}
|
Loading…
Reference in a new issue