1
This commit is contained in:
@@ -90,10 +90,16 @@ class TitleApiService {
|
||||
}
|
||||
|
||||
Map<String, dynamic> _processResponseBody(Uint8List bodyBytes) {
|
||||
final decrypted = _aesDecrypt(bodyBytes);
|
||||
final decompressed = _decompress(decrypted);
|
||||
final jsonStr = utf8.decode(decompressed);
|
||||
return jsonDecode(jsonStr) as Map<String, dynamic>;
|
||||
try {
|
||||
final decrypted = _aesDecrypt(bodyBytes);
|
||||
final decompressed = _decompress(decrypted);
|
||||
final jsonStr = utf8.decode(decompressed);
|
||||
return jsonDecode(jsonStr) as Map<String, dynamic>;
|
||||
} on FormatException catch (e) {
|
||||
throw TitleApiException('Response body is not valid JSON: $e');
|
||||
} on Exception catch (e) {
|
||||
throw TitleApiException('Failed to process response body: $e');
|
||||
}
|
||||
}
|
||||
|
||||
String _buildHash(String apiName) {
|
||||
@@ -155,6 +161,10 @@ class TitleApiService {
|
||||
throw TitleApiException('$apiName returned ${response.statusCode}');
|
||||
}
|
||||
|
||||
if (response.bodyBytes.isEmpty) {
|
||||
throw TitleApiException('$apiName returned empty body');
|
||||
}
|
||||
|
||||
final json = _processResponseBody(response.bodyBytes);
|
||||
final raw = const JsonEncoder.withIndent(' ').convert(json);
|
||||
// ignore: avoid_print
|
||||
|
||||
Reference in New Issue
Block a user