feat(bot): add error logging to topic processor

Previously, the topic processor swallowed errors silently, making debugging impossible. This commit adds error logging to the topic processor catch block.
This commit is contained in:
2026-03-14 14:43:32 +04:00
parent b44b3bde93
commit 572c21f621
2 changed files with 6 additions and 3 deletions

View File

@@ -157,7 +157,8 @@ const conversationalAssistant = createOpenAiChatAssistant(
const topicProcessor = createTopicProcessor(
runtime.openaiApiKey,
runtime.topicProcessorModel,
runtime.topicProcessorTimeoutMs
runtime.topicProcessorTimeoutMs,
getLogger('topic-processor')
)
const householdContextCache = new HouseholdContextCache()
const anonymousFeedbackRepositoryClients = new Map<

View File

@@ -245,7 +245,8 @@ function buildRecentMessagesSection(input: TopicProcessorInput): string | null {
export function createTopicProcessor(
apiKey: string | undefined,
model: string,
timeoutMs: number
timeoutMs: number,
logger?: { error: (obj: unknown, msg?: string) => void }
): TopicProcessor | undefined {
if (!apiKey) {
return undefined
@@ -506,7 +507,8 @@ If user dismisses ("не, забей", "cancel"), use dismiss_workflow.`
default:
return { route: 'silent', reason: 'unknown_route' }
}
} catch {
} catch (error) {
logger?.error({ event: 'topic_processor.failed', error }, 'Topic processor failed')
return null
} finally {
clearTimeout(timeout)