fix:对齐金值,主要注销,一键登录等方面修改
This commit is contained in:
1 parent
e29ed0a2c8
commit
6997a65c96
37 files changed
+3442
-514
No files matched your search
@@ -1,8 +1,27 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../../models/pb/errors/errors.pb.dart' as kerrors;
|
||||
|
||||
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.
|
||||
}
|
||||
}
|
||||
handler.next(err);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user