fromStreamedResponse static method
Parse an error response from the PowerSync service
Implementation
static Future<SyncResponseException> fromStreamedResponse(
http.StreamedResponse response) async {
try {
final body = await response.stream.bytesToString();
final decoded = convert.jsonDecode(body);
final details = _stringOrFirst(decoded['error']?['details']) ?? body;
final message = '${response.reasonPhrase ?? "Request failed"}: $details';
return SyncResponseException(response.statusCode, message);
} on Error catch (_) {
return SyncResponseException(
response.statusCode,
response.reasonPhrase ?? "Request failed",
);
}
}