{"record":{"id":"e7157213a129c36f","repo":"nikivdev/code","slug":"destination-cannot-be-inside-the-source-folder","errorCode":null,"errorMessage":"Destination cannot be inside the source folder.","messagePattern":"Destination cannot be inside the source folder\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/code.rs","lineNumber":291,"sourceCode":") -> Result<()> {\n    let target_display = target.display().to_string();\n    let action = if copy { \"copy\" } else { \"move\" };\n    let action_past = if copy { \"Copied\" } else { \"Moved\" };\n\n    if from == target {\n        bail!(\"Source and destination are the same path.\");\n    }\n    if !from.exists() {\n        bail!(\"Source folder does not exist: {}\", from.display());\n    }\n    if !from.is_dir() {\n        bail!(\"Source path is not a directory: {}\", from.display());\n    }\n    if target.exists() {\n        bail!(\"Destination already exists: {}\", target.display());\n    }\n    if target.starts_with(from) {\n        bail!(\"Destination cannot be inside the source folder.\");\n    }\n\n    // Create parent directories if needed\n    if let Some(parent) = target.parent() {\n        if !parent.exists() {\n            if dry_run {\n                println!(\"Would create {}\", parent.display());\n            } else {\n                fs::create_dir_all(parent)\n                    .with_context(|| format!(\"failed to create {}\", parent.display()))?;\n            }\n        }\n    }\n\n    if dry_run {\n        println!(\"Would {} {} -> {}\", action, from.display(), target_display);\n    } else if copy {\n        copy_dir_all(from, target)?;","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/code.rs#L273-L309","documentation":"Error \"Destination cannot be inside the source folder.\" thrown in nikivdev/code.","triggerScenarios":"Thrown at src/code.rs:291 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}