maotoumao/MusicFree · warning
panel.searchLrc.toast.failToSearch
Error message
panel.searchLrc.toast.failToSearch
What it means
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.
Source
Thrown at src/components/panels/types/searchLrc/LyricList.tsx:59
) : (
<FlashList
estimatedItemSize={ITEM_HEIGHT}
renderItem={({ item }) => (
<LyricItem
lyricItem={item}
onPress={async () => {
try {
const currentMusic = TrackPlayer.currentMusic;
if (!currentMusic) {
return;
}
lyricManager.associateLyric(currentMusic, item);
Toast.success(t("panel.searchLrc.toast.settingSuccess"));
hidePanel();
// 触发刷新歌词
} catch {
Toast.warn(t("panel.searchLrc.toast.failToSearch"));
}
}}
/>
)}
ListEmptyComponent={<ListEmpty state={searchState} />}
ListFooterComponent={data?.data?.length ? <ListFooter state={searchState} /> : null}
data={data?.data}
/>
);
}
const LyricList = memo(LyricListImpl, (prev, curr) => prev.data === curr.data);
View on GitHub (pinned to d118b18b3d)
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
Example fix
// before
} catch {
Toast.warn(t("panel.searchLrc.toast.failToSearch"));
}
// after
} catch (e) {
console.warn('associateLyric failed', e);
Toast.warn(t("panel.searchLrc.toast.failToSearch"));
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!item?.lyric || !currentMusic) return; // skip association when data is incomplete
Type guard
function isAssociatableResult(item: any): boolean {
return !!item && typeof item.lyric === 'string' && item.lyric.length > 0;
} Try / catch
try {
lyricManager.associateLyric(currentMusic, item);
Toast.success(t('panel.searchLrc.toast.settingSuccess'));
} catch (e) {
console.warn('associateLyric failed', e);
Toast.warn(t('panel.searchLrc.toast.failToSearch'));
} Prevention
- Bind and log the caught error instead of bare catch
- Validate search result items before associating
- Check network state before search operations
When it happens
Trigger: 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.
Common situations: Plugin returns malformed search results; network drops between search and selection; current music was changed/cleared while the list was open.
Related errors
- 搜索结果为空
- 安装失败: ${res.message}
- 当前无网络连接,请等待网络恢复后重试
- panel.associateLrc.targetExpired
- panel.associateLrc.toast.fail
AI-assisted analysis of maotoumao/MusicFree@d118b18b3d (2026-08-30).
Data as JSON: /api/errors/a3aef19f5ee95537.
Report an issue: GitHub.