{"record":{"id":"6297be89ea5fe68f","repo":"emilk/egui","slug":"err","errorCode":null,"errorMessage":"{err}","messagePattern":"\\{err\\}","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/egui_kittest/src/lib.rs","lineNumber":442,"sourceCode":"    ///\n    /// Returns the number of frames that were run.\n    ///\n    /// # Panics\n    /// Panics if the number of steps exceeds the maximum number of steps set\n    /// in [`HarnessBuilder::with_max_steps`].\n    ///\n    /// See also:\n    /// - [`Harness::try_run`].\n    /// - [`Harness::try_run_realtime`].\n    /// - [`Harness::run_ok`].\n    /// - [`Harness::step`].\n    /// - [`Harness::run_steps`].\n    #[track_caller]\n    pub fn run(&mut self) -> u64 {\n        match self.try_run() {\n            Ok(steps) => steps,\n            Err(err) => {\n                panic!(\"{err}\");\n            }\n        }\n    }\n\n    /// When `sleep` is true, each step sleeps for `self.step_dt`.\n    /// When `diagnostic` is true, we run extra steps to find [`ExceededMaxStepsError::steps_to_settle`].\n    fn try_run_impl(\n        &mut self,\n        sleep: bool,\n        diagnostic: bool,\n    ) -> Result<u64, ExceededMaxStepsError> {\n        // Once the budget is blown we keep going for a while, purely to find out how many steps\n        // would have been needed. The repaint causes are the ones from the moment we blew it.\n        let diagnostic_max_steps = if diagnostic {\n            config().diagnostic_max_steps()\n        } else {\n            0\n        };","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/emilk/egui/blob/441971a776322a482e371775219380eca812cfa9/crates/egui_kittest/src/lib.rs#L424-L460","documentation":"Harness::run is the infallible-facing wrapper around try_run: it executes the harness loop and panics with the error message if try_run returns Err. Any harness failure — max steps exceeded, snapshot mismatch, assertion failure — surfaces as this panic. Use try_run instead if you need to handle failures programmatically.","triggerScenarios":"Calling harness.run() when the underlying try_run fails: the UI never settles within max_steps, a snapshot comparison fails in Test mode, or a custom step/timeout error occurs.","commonSituations":"Snapshot mismatches after intentional UI changes (need UPDATE_SNAPSHOTS=1); animations preventing the UI from settling before max_steps is reached; flaky async UI timing in CI.","solutions":["Read the panic message to identify the underlying cause (snapshot mismatch vs exceeded max steps)","Re-run with UPDATE_SNAPSHOTS=1 (or =force) if snapshots changed intentionally","Increase max_steps or enable diagnostics if the UI never settles","Switch to try_run() to match on the error and handle failures without panicking"],"exampleFix":"// before\nlet steps = harness.run();\n// after\nmatch harness.try_run() {\n    Ok(steps) => steps,\n    Err(err) => eprintln!(\"harness failed: {err}\"),\n}","handlingStrategy":"try-catch","validationCode":"// cannot pre-validate; use try_run to check instead of run\nif let Err(err) = harness.try_run() {\n    eprintln!(\"harness would fail: {err}\");\n}","typeGuard":null,"tryCatchPattern":"match harness.try_run() {\n    Ok(steps) => println!(\"settled in {steps} steps\"),\n    Err(err) => eprintln!(\"harness failed: {err}\"),\n}","preventionTips":["Prefer try_run in test harness code where you want diagnostics instead of aborts","Keep snapshots in version control and update them deliberately via UPDATE_SNAPSHOTS","Raise max_steps or disable animations for UIs that take long to settle","Run snapshot tests in a consistent environment (same scale factor/DPI) as capture"],"tags":["rust","testing","panic","gui","snapshot"],"backgroundTag":"invalid-state-transition","analyzedSha":"441971a776322a482e371775219380eca812cfa9","analyzedAt":"2026-09-12T04:29:21.500Z","contentChangedAt":"2026-09-12T04:29:21.500Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}