{"record":{"id":"6b5e07d6ee97edd0","repo":"maotoumao/MusicFree","slug":"toast-copiedtoclipboardfailed","errorCode":null,"errorMessage":"toast.copiedToClipboardFailed","messagePattern":"toast\\.copiedToClipboardFailed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/components/panels/types/musicItemOptions.tsx","lineNumber":89,"sourceCode":"                            platform: musicItem.platform,\r\n                            id: musicItem.id,\r\n                        },\r\n                        null,\r\n                        \"\",\r\n                    ),\r\n                );\r\n                Toast.success(t(\"toast.copiedToClipboard\"));\r\n            },\r\n        },\r\n        {\r\n            icon: \"user\",\r\n            title: t(\"panel.musicItemOptions.author\", { artist: musicItem.artist }),\r\n            onPress: () => {\r\n                try {\r\n                    Clipboard.setString(musicItem.artist.toString());\r\n                    Toast.success(t(\"toast.copiedToClipboard\"));\r\n                } catch {\r\n                    Toast.warn(t(\"toast.copiedToClipboardFailed\"));\r\n                }\r\n            },\r\n        },\r\n        {\r\n            icon: \"album-outline\",\r\n            show: !!musicItem.album,\r\n            title: t(\"panel.musicItemOptions.album\", { album: musicItem.album }),\r\n            onPress: () => {\r\n                try {\r\n                    Clipboard.setString(musicItem.album.toString());\r\n                    Toast.success(t(\"toast.copiedToClipboard\"));\r\n                } catch {\r\n                    Toast.warn(t(\"toast.copiedToClipboardFailed\"));\r\n                }\r\n            },\r\n        },\r\n        {\r\n            icon: \"motion-play\",\r","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/maotoumao/MusicFree/blob/d118b18b3d0c904400f7eea7bf99c0ceec6c1aee/src/components/panels/types/musicItemOptions.tsx#L71-L107","documentation":"Toast shown when copying an artist name to the clipboard fails. onPress calls Clipboard.setString(musicItem.artist.toString()) inside try/catch; if the native clipboard API rejects (null/unavailable clipboard module, weird string content) the catch shows this warning.","triggerScenarios":"Tapping 'copy artist' when Clipboard.setString throws — react-native clipboard module unavailable in the current environment (e.g. web/Windows port without implementation) or the value cannot be serialized.","commonSituations":"Running on a platform where @react-native-clipboard/clipboard is not linked; musicItem.artist is an unusual object whose toString throws; headless/test environment without clipboard support.","solutions":["Verify the clipboard native module is linked (rebuild the app after installing @react-native-clipboard/clipboard)","Ensure musicItem.artist is a plain string or number before copying","Add a platform check and disable copy options where clipboard is unsupported"],"exampleFix":"// before\nClipboard.setString(musicItem.artist.toString());\n// after\nconst artistText = typeof musicItem.artist === 'string' ? musicItem.artist : String(musicItem.artist ?? '');\nif (artistText) Clipboard.setString(artistText);","handlingStrategy":"try-catch","validationCode":"if (musicItem?.artist == null) return;","typeGuard":"function hasCopyableArtist(m: any): m is IMusicItem {\n    return m?.artist != null && ['string','number'].includes(typeof m.artist);\n}","tryCatchPattern":"try {\n    Clipboard.setString(String(musicItem.artist));\n    Toast.success(t('toast.copiedToClipboard'));\n} catch {\n    Toast.warn(t('toast.copiedToClipboardFailed'));\n}","preventionTips":["Ensure the clipboard native module is linked and rebuilt","Coerce values to string before setString","Gate copy actions on platform clipboard availability"],"tags":["clipboard","ui"],"backgroundTag":"clipboard-write-failed","analyzedSha":"d118b18b3d0c904400f7eea7bf99c0ceec6c1aee","analyzedAt":"2026-08-30T11:49:12.932Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}