{"record":{"id":"47822e0fdc67deb9","repo":"DioxusLabs/dioxus","slug":"tried-to-access-ok-on-an-err-value","errorCode":null,"errorMessage":"Tried to access `ok` on an Err value","messagePattern":"Tried to access `ok` on an Err value","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/stores/src/impls/result.rs","lineNumber":96,"sourceCode":"    }\n\n    /// Converts `Store<Result<T, E>>` into `Option<Store<T>>`, discarding the error if present. This will\n    /// only track the shallow state of the `Result`. It will only cause a re-run if the `Result` could\n    /// change from `Err` to `Ok` or vice versa.\n    ///\n    /// # Example\n    /// ```rust, no_run\n    /// use dioxus_stores::*;\n    /// let store = use_store(|| Ok::<u32, ()>(42));\n    /// match store.ok() {\n    ///     Some(ok_store) => assert_eq!(ok_store(), 42),\n    ///     None => panic!(\"Expected Ok\"),\n    /// }\n    /// ```\n    pub fn ok(self) -> Option<MappedStore<T, Lens>> {\n        let map: fn(&Result<T, E>) -> &T = |value| {\n            value.as_ref().unwrap_or_else(|_| {\n                panic!(\"Tried to access `ok` on an Err value\");\n            })\n        };\n        let map_mut: fn(&mut Result<T, E>) -> &mut T = |value| {\n            value.as_mut().unwrap_or_else(|_| {\n                panic!(\"Tried to access `ok` on an Err value\");\n            })\n        };\n        self.is_ok()\n            .then(|| self.into_selector().child(0, map, map_mut).into())\n    }\n\n    /// Converts `Store<Result<T, E>>` into `Option<Store<E>>`, discarding the success if present. This will\n    /// only track the shallow state of the `Result`. It will only cause a re-run if the `Result` could\n    /// change from `Ok` to `Err` or vice versa.\n    ///\n    /// # Example\n    /// ```rust, no_run\n    /// use dioxus_stores::*;","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/stores/src/impls/result.rs#L78-L114","documentation":"`Store<Result<T,E>>::ok()` returns None when the store currently holds an Err value. The message surfaces if a store that must be Ok at this point is Err — i.e. the tracked Result state changed to (or was created as) Err while calling code assumed success. The docstring documents this shallow-tracking semantics; the panic text is the diagnostic shown when code unwraps through the Err branch.","triggerScenarios":"Thrown at packages/stores/src/impls/result.rs:96 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The Result value is Err. Match on the Result before accessing the ok payload."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24f6a829df0dfa203961a98ea4cae21c2ff27e28","analyzedAt":"2026-08-23T07:10:14.078Z","contentChangedAt":"2026-08-23T07:10:14.078Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}