Catch exception when parsing unexpected api call results

This commit is contained in:
Elias Müller 2023-06-07 22:26:23 +02:00
parent 7b52589d9e
commit f5afd7eb5e

View File

@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';
@ -44,8 +46,16 @@ abstract class TalkApi<T> extends ApiRequest {
}
//dynamic jsonData = jsonDecode(data.body);
T assembled;
try {
assembled = assemble(data.body);
return assembled;
} catch (_) {
// TODO report error
log("Error assembling Talk API response on $endpoint with body: $body and headers: ${headers.toString()}");
}
return assemble(data.body);
throw Exception("Error assembling Talk API response");
}
}