Catch exception when parsing unexpected api call results
This commit is contained in:
parent
7b52589d9e
commit
f5afd7eb5e
@ -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");
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user