DioxusLabs/dioxus · error

Tried to access `err` on an Ok value

Error message

Tried to access `err` on an Ok value

What it means

Store<Result<T,E>>::err was consumed where the Err case was required, but the store currently holds Ok. The err() projection only yields a store when the result is an error, so assuming its presence panics.

Solutions

  1. The Result value is Ok. Match on the Result before accessing the err payload.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at packages/stores/src/impls/result.rs:127 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/1011774cb9c379cb. Report an issue: GitHub.

Appendix: source

Thrown at packages/stores/src/impls/result.rs:127

    /// only track the shallow state of the `Result`. It will only cause a re-run if the `Result` could
    /// change from `Ok` to `Err` or vice versa.
    ///
    /// # Example
    /// ```rust, no_run
    /// use dioxus_stores::*;
    /// let store = use_store(|| Err::<(), u32>(42));
    /// match store.err() {
    ///     Some(err_store) => assert_eq!(err_store(), 42),
    ///     None => panic!("Expected Err"),
    /// }
    /// ```
    pub fn err(self) -> Option<MappedStore<E, Lens>>
    where
        Lens: Writable<Target = Result<T, E>> + 'static,
    {
        self.is_err().then(|| {
            let map: fn(&Result<T, E>) -> &E = |value| match value {
                Ok(_) => panic!("Tried to access `err` on an Ok value"),
                Err(e) => e,
            };
            let map_mut: fn(&mut Result<T, E>) -> &mut E = |value| match value {
                Ok(_) => panic!("Tried to access `err` on an Ok value"),
                Err(e) => e,
            };
            self.into_selector().child(1, map, map_mut).into()
        })
    }

    /// Transposes the `Store<Result<T, E>>` into a `Result<Store<T>, Store<E>>`. This will only track the
    /// shallow state of the `Result`. It will only cause a re-run if the `Result` could change from `Err` to
    /// `Ok` or vice versa.
    ///
    /// # Example
    /// ```rust, no_run
    /// use dioxus_stores::*;
    /// let store = use_store(|| Ok::<u32, ()>(42));

View on GitHub (pinned to 24f6a829df)