fix: ignore raw Dio blobs in API responses and replace email change dialog with a scrollable bottom sheet.
This commit is contained in:
@@ -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,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user