{"record":{"id":"5ee2e2f6485a1660","repo":"tonhowtf/omniget","slug":"e-to-string-publish","errorCode":null,"errorMessage":"e.to_string()","messagePattern":"e\\.to_string\\(\\)","errorType":"exception","errorClass":"IgError","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/instagram/publish.rs","lineNumber":308,"sourceCode":"        (\"is_meta_only_post\", \"0\".into()),\n    ]\n}\n\n/// Publica pela sessão web.\npub async fn publish_web(\n    client: &IgClient,\n    req: &PublishRequest,\n    progress: &super::super::ProgressFn,\n    job: &str,\n) -> anyhow::Result<PublishResult> {\n    let id = format!(\"ig:{}\", job);\n    if req.files.is_empty() {\n        return Err(anyhow!(\"escolha pelo menos um arquivo\"));\n    }\n    let report = |stage: &str, done: u64, total: u64| {\n        super::super::report(progress, &id, stage, done, Some(total), None)\n    };\n    let m = |e: IgError| anyhow!(e.to_string());\n    match req.kind.as_str() {\n        \"photo\" => {\n            report(\"upload\", 0, 2);\n            let uid = upload_id();\n            let (bytes, w, h) = as_jpeg(Path::new(&req.files[0])).await?;\n            rupload_photo(client, bytes, w, h, &uid, &[])\n                .await\n                .map_err(m)?;\n            report(\"configure\", 1, 2);\n            let json = client\n                .post_form(\"/api/v1/media/configure/\", &common_form(req, &uid))\n                .await\n                .map_err(m)?;\n            report(\"done\", 2, 2);\n            Ok(result_of(&json))\n        }\n        \"story\" => {\n            let path = Path::new(&req.files[0]);","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/instagram/publish.rs#L290-L326","documentation":"publish_web defines a local mapper m = |e: IgError| anyhow!(e.to_string()) used to convert Instagram client errors into anyhow errors at each upload/configure step; the surfaced message is the Display of the underlying IgError.","triggerScenarios":"Any Instagram API call inside publish_web (photo upload, video upload, carousel items, configure) returning Err(IgError) other than the special transcode/202 cases.","commonSituations":"Instagram session expired, media upload rejected (bad dimensions/duration), rate limiting, or transient HTTP failures during rupload.","solutions":["Read the stringified IgError to identify auth vs upload vs HTTP failure","Refresh Instagram login/session credentials if auth-related","Retry transient failures with backoff; respect rate limits","Validate media constraints (aspect ratio, duration, size) before upload"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-validate session and media before publish\nassert_session_valid(client)?;\nvalidate_media_constraints(&req.files)?;","typeGuard":null,"tryCatchPattern":"match publish_web(req, progress, job).await { Err(e) => { log::error!(\"publish failed: {e}\"); if e.to_string().to_lowercase().contains(\"login\") { reauth()?; } else { return Err(e); } }, ok => ok }","preventionTips":["Refresh Instagram session before long publish jobs","Check rate limits between uploads","Validate media dimensions/duration/size before upload"],"tags":["instagram","error-conversion","upload","rust"],"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"}