{"record":{"id":"1c05e0cad6f24b30","repo":"a-b-street/abstreet","slug":"couldn-t-read-all-of","errorCode":null,"errorMessage":"Couldn't read all of {}","messagePattern":"Couldn't read all of (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"widgetry/src/runner.rs","lineNumber":230,"sourceCode":"            window_title: window_title.to_string(),\n            #[cfg(target_arch = \"wasm32\")]\n            root_dom_element_id: \"widgetry-canvas\".to_string(),\n            assets_base_url: None,\n            assets_are_gzipped: false,\n            dump_raw_events: false,\n            scale_factor: None,\n            require_minimum_width: None,\n            window_icon: None,\n            loading_tips: None,\n            load_default_textures: true,\n            read_svg: Box::new(|path| {\n                use std::io::Read;\n\n                let mut file =\n                    fs_err::File::open(path).unwrap_or_else(|_| panic!(\"Couldn't read {}\", path));\n                let mut buffer = Vec::new();\n                file.read_to_end(&mut buffer)\n                    .unwrap_or_else(|_| panic!(\"Couldn't read all of {}\", path));\n                buffer\n            }),\n            canvas_settings: CanvasSettings::new(),\n        }\n    }\n\n    /// Log every raw winit event to the DEBUG level.\n    pub fn dump_raw_events(mut self) -> Self {\n        assert!(!self.dump_raw_events);\n        self.dump_raw_events = true;\n        self\n    }\n\n    /// Override the initial HiDPI scale factor from whatever winit initially detects.\n    pub fn scale_factor(mut self, scale_factor: f64) -> Self {\n        self.scale_factor = Some(scale_factor);\n        self\n    }","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/widgetry/src/runner.rs#L212-L248","documentation":"The default Settings::read_svg closure also panics if reading the opened file to the end fails (read_to_end errors). \"Couldn't read all of {path}\" means the file opened but its full contents could not be read (I/O error mid-read).","triggerScenarios":"read_to_end returning Err — e.g. the file is a directory-like special file, hardware/permission error occurs mid-read, or the underlying file was removed/truncated between open and read.","commonSituations":"Reading from network mounts or removable drives that disconnect, files being overwritten atomically (renamed away) during startup, corrupted filesystems.","solutions":["Retry the read; transient I/O errors often resolve on a second attempt.","Check disk/filesystem health for the volume holding the asset.","Ensure no external process deletes/renames assets while the app starts.","Provide a custom read_svg closure that returns an error result instead of panicking."],"exampleFix":"// before\nfile.read_to_end(&mut buffer).unwrap_or_else(|_| panic!(\"Couldn't read all of {}\", path));\n// after\nfile.read_to_end(&mut buffer).unwrap_or_else(|e| panic!(\"Couldn't read all of {}: {}\", path, e));","handlingStrategy":"retry","validationCode":"// Verify readability before handing the path to widgetry\nlet probe = std::fs::File::open(path).and_then(|mut f| f.read_to_end(&mut Vec::new()));\nif probe.is_err() { eprintln!(\"asset unreadable: {}\", path); }","typeGuard":null,"tryCatchPattern":"settings.read_svg = Box::new(|path| {\n    for _ in 0..3 {\n        match std::fs::read(path) { Ok(b) => return b, Err(_) => std::thread::sleep(std::time::Duration::from_millis(50)) }\n    }\n    Vec::new()\n});","preventionTips":["Keep assets on local disk, not network mounts","Avoid concurrent atomic renames of asset files during startup","Monitor disk health on machines running the app"],"tags":["rust","filesystem","io","svg"],"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"}