Merge pull request #153 from covespace/log_history_load_error

Add logger to TopicManager for better error handling
This commit is contained in:
boob.yang 2023-06-05 14:07:42 +08:00 committed by GitHub
commit f7bc5d08fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@ import DevChat, { LogEntry, LogOptions } from '../toolwrapper/devchat';
import { loadTopicList } from './loadTopics';
import { UiUtilWrapper } from '../util/uiUtil';
import { logger } from '../util/logger';
export class Topic {
name: string | undefined;
@ -281,11 +282,13 @@ export class TopicManager {
// 在DevChat日志中找出第一个hash为firstMessageHash的日志然后向下遍历直到找不到parentHash为当前日志hash的日志
const topic = this._topics[topicId];
if (!topic || !topic.firstMessageHash) {
logger.channel()?.info(`Topic ${topicId} not found`);
return [];
}
const logEntriesMap = await this.loadLogEntries();
if (!logEntriesMap[topic.firstMessageHash!]) {
logger.channel()?.info(`Topic ${topicId} not found in logEntriesMap`);
return [];
}