{"record":{"id":"797469a91dd119ad","repo":"tonhowtf/omniget","slug":"e-to-string","errorCode":null,"errorMessage":"e.to_string()","messagePattern":"e\\.to_string\\(\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/instagram/mod.rs","lineNumber":877,"sourceCode":"        Some(Value::Number(n)) => n.to_string(),\n        _ => String::new(),\n    }\n}\n\npub(crate) fn u(v: &Value, key: &str) -> u64 {\n    match v.get(key) {\n        Some(Value::Number(n)) => n.as_u64().unwrap_or(0),\n        Some(Value::String(x)) => x.parse().unwrap_or(0),\n        _ => 0,\n    }\n}\n\npub(crate) fn b(v: &Value, key: &str) -> bool {\n    v.get(key).and_then(|x| x.as_bool()).unwrap_or(false)\n}\n\npub fn map_err(e: IgError) -> anyhow::Error {\n    anyhow!(e.to_string())\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn shortcode_roundtrip() {\n        assert_eq!(shortcode_to_pk(\"B89prebFBcw\"), Some(2251138696266127152));\n        assert_eq!(pk_to_shortcode(2251138696266127152), \"B89prebFBcw\");\n        assert_eq!(shortcode_to_pk(\"Dc30nJeRKKz\"), Some(3978880184454783667));\n    }\n\n    #[test]\n    fn parses_targets() {\n        assert_eq!(\n            parse_target(\"https://www.instagram.com/p/B89prebFBcw/?igsh=abc\"),\n            IgTarget::Post {","sourceCodeStart":859,"sourceCodeEnd":895,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/instagram/mod.rs#L859-L895","documentation":"map_err converts an Instagram-specific IgError into an anyhow::Error by stringifying it with e.to_string(). It is a generic error-conversion boundary used by the Instagram tooling in omniget-core; the message you see is just the Display impl of the underlying IgError variant.","triggerScenarios":"Any call path in the instagram module that maps an IgError through map_err (e.g. HTTP failures, auth failures, JSON errors from Instagram responses bubbling up through publish/upload helpers).","commonSituations":"Expired Instagram session/cookies, Instagram returning an unexpected response, network failure during an upload, or an IgError::Other carrying an upstream message.","solutions":["Inspect the stringified message to identify the underlying IgError variant (auth vs network vs Other)","Re-authenticate or refresh Instagram session credentials if the message indicates auth failure","Retry transient network failures; check connectivity","If the message is an upstream Instagram error, log the full string and check Instagram API changes"],"exampleFix":"// before\nanyhow!(e.to_string())\n// after (preserve source chain for debugging)\nanyhow::Error::msg(e.to_string())","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match result { Err(e) => { log::error!(\"instagram: {e}\"); if is_auth_error(&e) { reauth()?; } } , Ok(v) => v }","preventionTips":["Keep session cookies/credentials fresh","Log the full stringified IgError, not just a generic message","Distinguish retryable (network) from permanent (auth/media) errors"],"tags":["rust","error-conversion","instagram","anyhow"],"backgroundTag":"api-error-response","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}