tonhowtf/omniget · error · anyhow

other.message()

Error message

other.message()

What it means

Generic catch-all in wait_for_token's polling loop: any Poll outcome other than Success/SlowDown/Pending/Expired (e.g. Poll::Denied) is converted to an anyhow error via its message(). Most commonly this is the user explicitly denying the authorization request on trakt.tv/activate.

Solutions

  1. Read the error message from Poll::other.message() to identify the exact outcome
  2. If denied, restart the flow with device_code() and have the user approve this time
  3. Ensure the user enters the code under the correct Trakt account
  4. Update match arms if Trakt introduced new poll statuses
Defensive patterns

Strategy: try-catch

Try / catch

match wait_for_token(&dc, progress).await {
    Err(e) => {
        let msg = e.to_string();
        if msg.contains("negad") || msg.contains("denied") {
            // explain denial and offer to restart device_code()
        } else {
            return Err(e);
        }
    }
    Ok(res) => { /* connected */ }
}

Prevention

When it happens

Trigger: The device-token poll endpoint returns a terminal status that maps to an unhandled Poll variant — typically Deny when the user clicks 'deny' during activation.

Common situations: User denied the request at trakt.tv/activate; an unrecognized poll response maps to a new Poll variant the caller did not anticipate.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/1113d5da9db7708c. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/lists/trakt.rs:342

                "client_secret": c.client_secret,
            }))
            .send()
            .await?;
        let status = r.status().as_u16();
        match poll_state(status) {
            Poll::Done => {
                let v: Value = r.json().await?;
                let username = save_token(&v)?;
                report(&p, TOOL_ID, "done", 1, Some(1), None);
                return Ok(ConnectResult {
                    connected: true,
                    username: username.clone(),
                    message: format!("conectado como {}", username),
                });
            }
            Poll::SlowDown => interval += Duration::from_secs(dc.interval.max(1)),
            Poll::Pending => {}
            other => return Err(anyhow!("{}", other.message())),
        }
    }
}

fn save_token(v: &Value) -> Result<String> {
    let access = v
        .get("access_token")
        .and_then(|x| x.as_str())
        .unwrap_or_default()
        .to_string();
    if access.is_empty() {
        return Err(anyhow!("o Trakt não devolveu o token"));
    }
    let refresh = v
        .get("refresh_token")
        .and_then(|x| x.as_str())
        .unwrap_or_default()
        .to_string();

View on GitHub (pinned to 8600b91f42)