{"record":{"id":"a926de21c15c0db1","repo":"a-b-street/abstreet","slug":"unsupported-on-web","errorCode":null,"errorMessage":"Unsupported on web","messagePattern":"Unsupported on web","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"widgetry/src/tools/mod.rs","lineNumber":132,"sourceCode":"pub fn get_clipboard() -> Result<String> {\n    #[cfg(not(target_arch = \"wasm32\"))]\n    {\n        use clipboard::{ClipboardContext, ClipboardProvider};\n        // TODO The clipboard crate uses old nightly Errors. Converting to anyhow is weird.\n        let mut ctx: ClipboardContext = match ClipboardProvider::new() {\n            Ok(ctx) => ctx,\n            Err(err) => bail!(\"{}\", err),\n        };\n        let contents = match ctx.get_contents() {\n            Ok(contents) => contents,\n            Err(err) => bail!(\"{}\", err),\n        };\n        Ok(contents)\n    }\n\n    #[cfg(target_arch = \"wasm32\")]\n    {\n        bail!(\"Unsupported on web\");\n    }\n}\n","sourceCodeStart":114,"sourceCodeEnd":135,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/widgetry/src/tools/mod.rs#L114-L135","documentation":"get_clipboard is only implemented for native targets; on wasm32 the function unconditionally bails with \"Unsupported on web\". The browser clipboard API is not wired up in this library, so any wasm build calling this will always fail. It is a deliberate platform limitation, not a runtime fault.","triggerScenarios":"Calling widgetry::tools::get_clipboard() from any code compiled to wasm32 (the web build of the app).","commonSituations":"Shared code that pastes from clipboard runs unmodified in the browser build; feature-gating was forgotten when porting desktop functionality to web.","solutions":["Gate the call with #[cfg(not(target_arch = \"wasm32\"))] and provide a web alternative using navigator.clipboard.readText()","Use cfg! or a trait to supply a platform-specific clipboard implementation","Disable the paste-from-clipboard UI affordance in the web build","Return an empty string / show a 'not supported on web' message to the user"],"exampleFix":"// before\nlet text = get_clipboard()?;\n// after\n#[cfg(target_arch = \"wasm32\")]\nlet text = String::new(); // or use wasm bindgen clipboard API\n#[cfg(not(target_arch = \"wasm32\"))]\nlet text = get_clipboard()?;","handlingStrategy":"type-guard","validationCode":"let supported = cfg!(not(target_arch = \"wasm32\"));","typeGuard":"fn clipboard_supported() -> bool {\n    cfg!(not(target_arch = \"wasm32\"))\n}","tryCatchPattern":"if cfg!(target_arch = \"wasm32\") {\n    // use navigator.clipboard.readText() via wasm-bindgen instead\n} else {\n    let text = get_clipboard()?;\n}","preventionTips":["Feature-gate clipboard calls with cfg(target_arch)","Provide a web implementation using navigator.clipboard","Hide copy/paste-from-clipboard UI in the web build","Centralize platform capabilities in one helper instead of scattering cfgs"],"tags":["clipboard","wasm","web","unsupported-platform"],"backgroundTag":"unsupported-platform","analyzedSha":"0964f29315820c91b171b585eb51e300164e9197","analyzedAt":"2026-09-13T18:02:03.421Z","contentChangedAt":"2026-09-13T18:02:03.421Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}