fix:参考金值,研听,研值工程通用通用工程公共能力,重点对比网络请求、登录认证、状态管理、本地存储、WebView、推送、版本更新、一键登录、主题/UI 等模块,确定后续统一整改方案

This commit is contained in:
jingyun committed 2026-09-10 09:52:36 +08:00
1 parent 6997a65c96
commit d364c6d908
46 files changed
+2060 -395

No files matched your search

@@ -1,27 +1,16 @@
import 'package:dio/dio.dart';
import '../../models/pb/errors/errors.pb.dart' as kerrors;
import 'api_exception.dart';
class KratosErrorInterceptor extends Interceptor {
@override
void onError(DioException err, ErrorInterceptorHandler handler) {
final response = err.response;
final raw = response?.data;
if (response != null && raw is List<int> && raw.isNotEmpty) {
try {
final status = kerrors.Status.fromBuffer(raw);
if (status.code != 0 || status.reason.isNotEmpty) {
response.data = <String, dynamic>{
'code': status.code,
'reason': status.reason,
'message': status.message,
'metadata': status.metadata,
};
}
} catch (_) {
// A non-Kratos error body keeps its original representation.
}
if (err.error is ApiException) {
handler.next(err);
return;
}
handler.next(err);
// Preserve response.data for diagnostics and retries. The parsed error is
// carried as DioException.error and normalized by ApiException.from().
handler.next(err.copyWith(error: ApiException.fromDio(err)));
}
}