{"record":{"id":"a3aef19f5ee95537","repo":"maotoumao/MusicFree","slug":"panel-searchlrc-toast-failtosearch","errorCode":null,"errorMessage":"panel.searchLrc.toast.failToSearch","messagePattern":"panel\\.searchLrc\\.toast\\.failToSearch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/components/panels/types/searchLrc/LyricList.tsx","lineNumber":59,"sourceCode":"    ) : (\n        <FlashList\n            estimatedItemSize={ITEM_HEIGHT}\n            renderItem={({ item }) => (\n                <LyricItem\n                    lyricItem={item}\n                    onPress={async () => {\n                        try {\n                            const currentMusic = TrackPlayer.currentMusic;\n                            if (!currentMusic) {\n                                return;\n                            }\n\n                            lyricManager.associateLyric(currentMusic, item);\n                            Toast.success(t(\"panel.searchLrc.toast.settingSuccess\"));\n                            hidePanel();\n                            // 触发刷新歌词\n                        } catch {\n                            Toast.warn(t(\"panel.searchLrc.toast.failToSearch\"));\n                        }\n                    }}\n                />\n            )}\n            ListEmptyComponent={<ListEmpty state={searchState} />}\n            ListFooterComponent={data?.data?.length ? <ListFooter state={searchState} /> : null}\n            data={data?.data}\n        />\n    );\n}\n\nconst LyricList = memo(LyricListImpl, (prev, curr) => prev.data === curr.data);\n","sourceCodeStart":41,"sourceCodeEnd":72,"githubUrl":"https://github.com/maotoumao/MusicFree/blob/d118b18b3d0c904400f7eea7bf99c0ceec6c1aee/src/components/panels/types/searchLrc/LyricList.tsx#L41-L72","documentation":"Generic failure toast in the online lyric-search list. When the user picks a lyric result, the handler associates it with the current music (lyricManager.associateLyric) inside a try/catch with no error binding — any throw (search/association failure, invalid result item) shows 'failToSearch' even though the failure is in association, not search.","triggerScenarios":"Pressing a lyric search result when associateLyric or the surrounding await chain throws — result item missing required fields (lyric text, id), currentMusic invalid, or network fetch of the lyric body failing.","commonSituations":"Plugin returns malformed search results; network drops between search and selection; current music was changed/cleared while the list was open.","solutions":["Log the caught error (the catch swallows it) to find the real cause","Verify the selected result item has valid lyric content/id from the plugin","Check network connectivity and retry the search","Reopen the panel so currentMusic is fresh"],"exampleFix":"// before\n} catch {\n    Toast.warn(t(\"panel.searchLrc.toast.failToSearch\"));\n}\n// after\n} catch (e) {\n    console.warn('associateLyric failed', e);\n    Toast.warn(t(\"panel.searchLrc.toast.failToSearch\"));\n}","handlingStrategy":"try-catch","validationCode":"if (!item?.lyric || !currentMusic) return; // skip association when data is incomplete","typeGuard":"function isAssociatableResult(item: any): boolean {\n    return !!item && typeof item.lyric === 'string' && item.lyric.length > 0;\n}","tryCatchPattern":"try {\n    lyricManager.associateLyric(currentMusic, item);\n    Toast.success(t('panel.searchLrc.toast.settingSuccess'));\n} catch (e) {\n    console.warn('associateLyric failed', e);\n    Toast.warn(t('panel.searchLrc.toast.failToSearch'));\n}","preventionTips":["Bind and log the caught error instead of bare catch","Validate search result items before associating","Check network state before search operations"],"tags":["lyrics","network","search"],"backgroundTag":"lyric-associate-failed","analyzedSha":"d118b18b3d0c904400f7eea7bf99c0ceec6c1aee","analyzedAt":"2026-08-30T11:49:12.932Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}