parseRPCError static method
void
parseRPCError(
- dynamic json
Implementation
static void parseRPCError(json) {
var errors = '';
try {
var arr = json is List ? json : [json];
if (json[0]['kind'] != null) {
errors = arr.fold(
'',
(previousValue, element) =>
'$previousValue${element['kind']} : ${element['id']}, ');
} else if (arr.length == 1 &&
arr[0]['contents'].length == 1 &&
arr[0]['contents'][0]['kind'].toString() == "activate_account") {
} else {}
} catch (err) {
if (json.toString().startsWith('Failed to parse the request body: ')) {
errors = json.toString().toString().substring(34);
} else {
var hash = json
.toString()
.replaceFirst('/\"/g', "'")
.replaceFirst('/\n/', "'");
if (hash.length == 51 && hash[0] == 'o') {
} else {
throw Exception(
"failed to parse errors: '$err' from '${json.toString()}'\n, PLEASE report this to the maintainers");
}
}
}
if (errors.length > 0) {
throw Exception(errors);
}
}