added verbose error body in case of errors
This commit is contained in:
@@ -60,7 +60,15 @@ abstract class TalkApi<T extends ApiResponse?> extends ApiRequest {
|
|||||||
|
|
||||||
final status = data.statusCode;
|
final status = data.statusCode;
|
||||||
if (status < 200 || status >= 300) {
|
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);
|
log(detail);
|
||||||
if (status == 401) {
|
if (status == 401) {
|
||||||
throw AuthException.unauthorized(technicalDetails: detail);
|
throw AuthException.unauthorized(technicalDetails: detail);
|
||||||
|
|||||||
Reference in New Issue
Block a user