{"record":{"id":"f16d944417922438","repo":"emilk/egui","slug":"err-snapshot","errorCode":null,"errorMessage":"{err}","messagePattern":"\\{err\\}","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/egui_kittest/src/snapshot.rs","lineNumber":665,"sourceCode":"///\n/// The snapshot files will be saved under [`SnapshotOptions::output_path`].\n/// The snapshot will be saved under `{output_path}/{name}.png`.\n/// The new image from the most recent test run will be saved under `{output_path}/{name}.new.png`.\n/// If the new image didn't match the snapshot, a diff image will be saved under `{output_path}/{name}.diff.png`.\n///\n/// # Panics\n/// Panics if the image does not match the snapshot or if there was an error reading or writing the\n/// snapshot.\n#[track_caller]\npub fn image_snapshot_options(\n    current: &image::RgbaImage,\n    name: impl Into<String>,\n    options: &SnapshotOptions,\n) {\n    match try_image_snapshot_options(current, name, options) {\n        Ok(()) => {}\n        Err(err) => {\n            panic!(\"{err}\");\n        }\n    }\n}\n\n/// Image snapshot test.\n///\n/// The snapshot will be saved under `tests/snapshots/{name}.png`.\n/// The new image from the last test run will be saved under `tests/snapshots/{name}.new.png`.\n/// If the new image didn't match the snapshot, a diff image will be saved under `tests/snapshots/{name}.diff.png`.\n///\n/// # Panics\n/// Panics if the image does not match the snapshot or if there was an error reading or writing the\n/// snapshot.\n#[track_caller]\npub fn image_snapshot(current: &image::RgbaImage, name: impl Into<String>) {\n    match try_image_snapshot(current, name) {\n        Ok(()) => {}\n        Err(err) => {","sourceCodeStart":647,"sourceCodeEnd":683,"githubUrl":"https://github.com/emilk/egui/blob/441971a776322a482e371775219380eca812cfa9/crates/egui_kittest/src/snapshot.rs#L647-L683","documentation":"image_snapshot_options is the panicking wrapper around try_image_snapshot_options: it performs the snapshot comparison and panics with the error message if the snapshot fails (mismatch, missing reference, write error, etc.). It exists so tests can simply call it and abort on any snapshot failure. Use try_image_snapshot_options for non-panicking handling.","triggerScenarios":"Calling image_snapshot_options (or harness.snapshot()) when the current image differs from the stored snapshot beyond the diff threshold, the reference snapshot file does not yet exist in Test mode, or writing/reading snapshot files fails.","commonSituations":"A UI change (new font, scaling, theme) altering rendered output; running tests on a platform/DPI with different rendering than snapshots were captured on; forgetting to commit new reference snapshots created in update mode.","solutions":["Inspect the diff image written next to the snapshot to see what changed","Re-run with UPDATE_SNAPSHOTS=1 to accept intentional visual changes, then commit the updated snapshots","Check for DPI/scale/platform differences between capture and test environments","Use try_image_snapshot_options if you need custom failure handling instead of a panic"],"exampleFix":"// before\nimage_snapshot_options(&image, \"my_snapshot\", &options);\n// after\nif let Err(err) = try_image_snapshot_options(&image, \"my_snapshot\", &options) {\n    eprintln!(\"snapshot failed: {err}\");\n}","handlingStrategy":"try-catch","validationCode":"// ensure the reference snapshot exists before a Test-mode comparison\nlet snapshot_path = std::path::Path::new(\"snapshots/my_snapshot.png\");\nassert!(snapshot_path.exists(), \"reference snapshot missing; run with UPDATE_SNAPSHOTS=1 first\");","typeGuard":null,"tryCatchPattern":"match try_image_snapshot_options(&image, \"my_snapshot\", &options) {\n    Ok(()) => {}\n    Err(err) => eprintln!(\"snapshot mismatch: {err}\"),\n}","preventionTips":["Pin rendering conditions (DPI, fonts, scale factor) between capture and test runs","Commit reference snapshots after intentional UI changes","Review diff images generated on failure before re-capturing","Use try_* variants in shared tooling where a panic would abort the whole suite"],"tags":["rust","testing","snapshot","image","panic"],"backgroundTag":"checksum-mismatch","analyzedSha":"441971a776322a482e371775219380eca812cfa9","analyzedAt":"2026-09-12T04:29:21.500Z","contentChangedAt":"2026-09-12T04:29:21.500Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}