{"record":{"id":"e82f681155db75bf","repo":"DioxusLabs/dioxus","slug":"failed-to-format-file","errorCode":null,"errorMessage":"Failed to format file","messagePattern":"Failed to format file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/autofmt/src/lib.rs","lineNumber":46,"sourceCode":"pub struct FormattedBlock {\n    /// The new contents of the block\n    pub formatted: String,\n\n    /// The line number of the first line of the block.\n    pub start: usize,\n\n    /// The end of the block, exclusive.\n    pub end: usize,\n}\n\n/// Format a file into a list of `FormattedBlock`s to be applied by an IDE for autoformatting.\n///\n/// It accepts\n#[deprecated(note = \"Use try_fmt_file instead - this function panics on error.\")]\npub fn fmt_file(contents: &str, indent: IndentOptions) -> Vec<FormattedBlock> {\n    let parsed =\n        syn::parse_file(contents).expect(\"fmt_file should only be called on valid syn::File files\");\n    try_fmt_file(contents, &parsed, indent).expect(\"Failed to format file\")\n}\n\n/// Format a file into a list of `FormattedBlock`s to be applied by an IDE for autoformatting.\n///\n/// This function expects a complete file, not just a block of code. To format individual rsx! blocks, use fmt_block instead.\n///\n/// The point here is to provide precise modifications of a source file so an accompanying IDE tool can map these changes\n/// back to the file precisely.\n///\n/// Nested blocks of RSX will be handled automatically\n///\n/// This returns an error if the rsx itself is invalid.\n///\n/// Will early return if any of the expressions are not complete. Even though we *could* return the\n/// expressions, eventually we'll want to pass off expression formatting to rustfmt which will reject\n/// those.\npub fn try_fmt_file(\n    contents: &str,","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/autofmt/src/lib.rs#L28-L64","documentation":"`fmt_file` is the deprecated panic-on-error formatter; it calls `syn::parse_file` and `expect`s success. This panic fires when the given source cannot be parsed as valid Rust. The deprecation note points users to `try_fmt_file`, which returns the error instead.","triggerScenarios":"Thrown at packages/autofmt/src/lib.rs:46 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the file for syntax errors that prevent formatting, and ensure rustfmt-compatible input; inspect the underlying error for details."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24f6a829df0dfa203961a98ea4cae21c2ff27e28","analyzedAt":"2026-08-23T07:10:14.078Z","contentChangedAt":"2026-08-23T07:10:14.078Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}