added verbose error body in case of errors

This commit is contained in:
2026-05-13 18:37:50 +02:00
parent 37dbb7b374
commit a09817a975
+9 -1
View File
@@ -60,7 +60,15 @@ abstract class TalkApi<T extends ApiResponse?> extends ApiRequest {
final status = data.statusCode;
if (status < 200 || status >= 300) {
final detail = 'Talk $endpoint -> HTTP $status';
// Talk's OCS errors put the real reason in the response body (e.g.
// expired session, removed participant, malformed reply target).
// Include a trimmed preview so the in-app error dialog and logs
// surface the cause instead of just the bare status code.
final body = data.body.replaceAll(RegExp(r'\s+'), ' ').trim();
final preview = body.length > 500 ? '${body.substring(0, 500)}' : body;
final detail = body.isEmpty
? 'Talk $endpoint -> HTTP $status'
: 'Talk $endpoint -> HTTP $status body=$preview';
log(detail);
if (status == 401) {
throw AuthException.unauthorized(technicalDetails: detail);