{"record":{"id":"ea3913807a30974c","repo":"a-b-street/abstreet","slug":"can-t-read","errorCode":null,"errorMessage":"Can't read {}: {}","messagePattern":"Can't read (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"abstio/src/lib.rs","lineNumber":39,"sourceCode":"#[cfg(not(target_arch = \"wasm32\"))]\nmod download;\n#[cfg(not(target_arch = \"wasm32\"))]\npub use download::*;\n\npub use abst_data::*;\npub use abst_paths::*;\npub use http::*;\n\nmod abst_data;\nmod abst_paths;\nmod http;\nmod io;\n\n/// An adapter for widgetry::Settings::read_svg to read SVGs using this crate's methods for finding\n/// and reading files in different environments.\npub fn slurp_bytes(filename: &str) -> Vec<u8> {\n    let path = path(filename);\n    slurp_file(&path).unwrap_or_else(|err| panic!(\"Can't read {}: {}\", path, err))\n}\n","sourceCodeStart":21,"sourceCodeEnd":41,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/abstio/src/lib.rs#L21-L41","documentation":"slurp_bytes resolves a filename via the crate's environment-aware path() lookup and reads the whole file into memory. If slurp_file returns an error (missing file, permission denied, IO error), it panics with \"Can't read {path}: {err}\". This is an intentional abort: the caller asked for an asset the library assumes must exist (e.g. an SVG read by widgetry's settings).","triggerScenarios":"Calling abstio::slurp_bytes(filename) where path(filename) does not exist, is unreadable (permissions), or the underlying read fails with an IO error. Common with SVG assets passed to widgetry::Settings::read_svg.","commonSituations":"Running the app from the wrong working directory so relative asset paths don't resolve; a missing/misnamed SVG resource; deployment packaging that omitted asset files; permission-restricted data directories.","solutions":["Verify the file exists at the resolved path (abstio::path(filename) plus std::path::Path::exists) before calling slurp_bytes.","Run the binary from the repo root or set the correct data directory so relative asset paths resolve.","Use abstio::slurp_file with Result handling (or maybe_slurp) if a missing file is an expected, recoverable condition instead of slurp_bytes.","Check file permissions and that packaging/deploy includes the asset files."],"exampleFix":"// before\nlet bytes = abstio::slurp_bytes(\"icons/pin.svg\");\n// after\nlet path = abstio::path(\"icons/pin.svg\");\nif !std::path::Path::new(&path).exists() {\n    eprintln!(\"missing asset {}\", path);\n    return;\n}\nlet bytes = abstio::slurp_bytes(\"icons/pin.svg\");","handlingStrategy":"validation","validationCode":"let path = abstio::path(\"icons/pin.svg\");\nassert!(std::path::Path::new(&path).exists(), \"missing asset: {}\", path);","typeGuard":null,"tryCatchPattern":"// panics; cannot catch in Rust. Pre-check instead:\nmatch abstio::slurp_file(&abstio::path(name)) {\n    Ok(bytes) => use(bytes),\n    Err(e) => eprintln!(\"skipping {}: {}\", name, e),\n}","preventionTips":["Run binaries from the repo root or set the data directory explicitly.","Add asset existence checks in CI packaging steps.","Prefer Result-returning slurp_file when a missing file is expected."],"tags":["panic","file-io","missing-file","assets"],"backgroundTag":"file-read-failed","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"}