fix(account): 本地化网络异常文案
This commit is contained in:
1 parent
9b3ab9d5de
commit
27ab7cebfb
5 files changed
+90
-11
No files matched your search
@@ -68,10 +68,12 @@ class FakeAccountRepository implements AccountRepository {
|
||||
bool failUpdate = false;
|
||||
bool failDeactivate = false;
|
||||
bool failCancel = false;
|
||||
bool throwUnexpected = false;
|
||||
|
||||
@override
|
||||
Future<AccountProfile> profile() async {
|
||||
profileCalls++;
|
||||
if (throwUnexpected) throw StateError('offline');
|
||||
if (failProfile) throw const ApiException(500, '资料加载失败');
|
||||
return _profile;
|
||||
}
|
||||
@@ -79,6 +81,7 @@ class FakeAccountRepository implements AccountRepository {
|
||||
@override
|
||||
Future<AccountProfile> updateProfile(AccountProfileUpdate update) async {
|
||||
lastUpdate = update;
|
||||
if (throwUnexpected) throw StateError('offline');
|
||||
if (failUpdate) throw const ApiException(400, '昵称不可用');
|
||||
_profile = AccountProfile(
|
||||
uid: _profile.uid,
|
||||
@@ -100,6 +103,7 @@ class FakeAccountRepository implements AccountRepository {
|
||||
@override
|
||||
Future<List<AccountDevice>> devices() async {
|
||||
deviceCalls++;
|
||||
if (throwUnexpected) throw StateError('offline');
|
||||
if (failDevices) throw const ApiException(500, '设备加载失败');
|
||||
return [..._devices];
|
||||
}
|
||||
@@ -107,6 +111,7 @@ class FakeAccountRepository implements AccountRepository {
|
||||
@override
|
||||
Future<AccountExport> export() async {
|
||||
exportCalls++;
|
||||
if (throwUnexpected) throw StateError('offline');
|
||||
if (failExport) throw const ApiException(500, '导出失败');
|
||||
return _export;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user