fix: ignore raw Dio blobs in API responses and replace email change dialog with a scrollable bottom sheet.

This commit is contained in:
pradeepkumar
2026-05-06 14:35:35 +05:30
parent 8845e77274
commit ff71a50229
2 changed files with 239 additions and 82 deletions

View File

@@ -255,20 +255,31 @@ class ApiClient {
: rawMessage?.toString();
if (message != null && message.isNotEmpty) {
final errors = (dataMap['errors'] as List<dynamic>?)
?.map((e) => FieldError.fromJson(e as Map<String, dynamic>))
.toList() ??
[];
// Defensive: if the backend echoed back the raw Dio exception
// toString (e.g. "ApiException: This exception was thrown..."),
// ignore it and fall through to the friendly status-code message.
final looksLikeRawDioBlob =
message.startsWith('ApiException:') ||
message.contains('RequestOptions.validateStatus') ||
message.contains('This exception was thrown because');
return DioException(
requestOptions: error.requestOptions,
response: error.response,
error: ApiException(
message: message,
statusCode: response.statusCode,
fieldErrors: errors,
),
);
if (!looksLikeRawDioBlob) {
final errors = (dataMap['errors'] as List<dynamic>?)
?.map(
(e) => FieldError.fromJson(e as Map<String, dynamic>))
.toList() ??
[];
return DioException(
requestOptions: error.requestOptions,
response: error.response,
error: ApiException(
message: message,
statusCode: response.statusCode,
fieldErrors: errors,
),
);
}
}
}
}