fix(app): 18 处 catch(e) 添加 debugPrint 异常日志
- parent_bloc: 6 处 (LoadChildren/BindChild/ViewJournals/ExportData/DeleteData/UnbindChild) - search_bloc: 3 处 (SearchByMood/SearchByTag/SearchByKeyword) - achievement_bloc: 1 处 (_fetchAchievements) - sticker_bloc: 2 处 (_fetchPacks/fetchStickersInPack) - template_bloc: 1 处 (_fetchTemplates) - mood_bloc: 1 处 (_loadStats) - home_bloc: 1 处 (_onLoadData) - calendar_bloc: 1 处 (_onMonthChanged) - sync_engine: 1 处 (trySync) - weekly_page: 已有 debugPrint,无需修改
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// 状态机: ParentInitial → ParentLoading → ParentChildrenLoaded / ParentJournalsLoaded / ParentDataExported / ParentDataDeleted / ParentError
|
||||
// API: /diary/parent/* 端点
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../data/remote/api_client.dart';
|
||||
@@ -40,6 +41,7 @@ class ParentBloc extends Bloc<ParentEvent, ParentState> {
|
||||
.toList();
|
||||
emit(ParentChildrenLoaded(children));
|
||||
} catch (e) {
|
||||
debugPrint('ParentBloc._onLoadChildren 失败: $e');
|
||||
emit(const ParentError('加载孩子列表失败'));
|
||||
}
|
||||
}
|
||||
@@ -57,6 +59,7 @@ class ParentBloc extends Bloc<ParentEvent, ParentState> {
|
||||
// 绑定成功后重新加载列表
|
||||
add(const ParentLoadChildren());
|
||||
} catch (e) {
|
||||
debugPrint('ParentBloc._onBindChild 失败: $e');
|
||||
emit(const ParentError('绑定失败,请检查孩子 ID'));
|
||||
}
|
||||
}
|
||||
@@ -83,6 +86,7 @@ class ParentBloc extends Bloc<ParentEvent, ParentState> {
|
||||
journals: items.cast<Map<String, dynamic>>(),
|
||||
));
|
||||
} catch (e) {
|
||||
debugPrint('ParentBloc._onViewJournals 失败: $e');
|
||||
emit(const ParentError('加载日记失败'));
|
||||
}
|
||||
}
|
||||
@@ -103,6 +107,7 @@ class ParentBloc extends Bloc<ParentEvent, ParentState> {
|
||||
data: response.data as Map<String, dynamic>,
|
||||
));
|
||||
} catch (e) {
|
||||
debugPrint('ParentBloc._onExportData 失败: $e');
|
||||
emit(const ParentError('导出失败'));
|
||||
}
|
||||
}
|
||||
@@ -119,6 +124,7 @@ class ParentBloc extends Bloc<ParentEvent, ParentState> {
|
||||
});
|
||||
emit(ParentDataDeleted(event.childId));
|
||||
} catch (e) {
|
||||
debugPrint('ParentBloc._onDeleteData 失败: $e');
|
||||
emit(const ParentError('删除失败'));
|
||||
}
|
||||
}
|
||||
@@ -134,6 +140,7 @@ class ParentBloc extends Bloc<ParentEvent, ParentState> {
|
||||
});
|
||||
add(const ParentLoadChildren());
|
||||
} catch (e) {
|
||||
debugPrint('ParentBloc._onUnbindChild 失败: $e');
|
||||
emit(const ParentError('解绑失败'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user