{"record":{"id":"5d599891700df4e6","repo":"pemistahl/grex","slug":"builder","errorCode":null,"errorMessage":"{}","messagePattern":"\\{\\}","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/builder.rs","lineNumber":83,"sourceCode":"    /// ⚠ Panics if:\n    /// - the file cannot be found\n    /// - the file's encoding is not valid UTF-8 data\n    /// - the file cannot be opened because of conflicting permissions\n    pub fn from_file<T: Into<PathBuf>>(file_path: T) -> Self {\n        match std::fs::read_to_string(file_path.into()) {\n            Ok(file_content) => Self {\n                test_cases: file_content.lines().map(|it| it.to_string()).collect_vec(),\n                config: RegExpConfig::new(),\n            },\n            Err(error) => match error.kind() {\n                ErrorKind::NotFound => panic!(\"The specified file could not be found\"),\n                ErrorKind::InvalidData => {\n                    panic!(\"The specified file's encoding is not valid UTF-8\")\n                }\n                ErrorKind::PermissionDenied => {\n                    panic!(\"Permission denied: The specified file could not be opened\")\n                }\n                _ => panic!(\"{}\", error),\n            },\n        }\n    }\n\n    /// Converts any Unicode decimal digit to character class `\\d`.\n    ///\n    /// This method takes precedence over\n    /// [`with_conversion_of_words`](Self::with_conversion_of_words) if both are set.\n    /// Decimal digits are converted to `\\d`, the remaining word characters to `\\w`.\n    ///\n    /// This method takes precedence over\n    /// [`with_conversion_of_non_whitespace`](Self::with_conversion_of_non_whitespace) if both are set.\n    /// Decimal digits are converted to `\\d`, the remaining non-whitespace characters to `\\S`.\n    pub fn with_conversion_of_digits(&mut self) -> &mut Self {\n        self.config.is_digit_converted = true;\n        self\n    }\n","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/pemistahl/grex/blob/99cc347707375e00514f938b76d885a201dfc110/src/builder.rs#L65-L101","documentation":"This is the catch-all branch of RegExpBuilder::from_file: any std::io::Error whose kind is not NotFound, InvalidData, or PermissionDenied is interpolated directly into the panic message ('{}'). It surfaces the raw OS error text, e.g. 'Is a directory (os error 21)'.","triggerScenarios":"Calling from_file with a path to a directory (IsADirectory), a path with too many symlinks, an interrupted-but-undetectable io error, or any platform-specific io failure outside the three special-cased kinds.","commonSituations":"Passing a directory path by mistake; a path that resolves through a symlink loop; exotic filesystems returning unusual error kinds.","solutions":["Confirm the path points to a regular file (Path::is_file) and not a directory or device","Read the file yourself with std::fs::read_to_string and match on the io::Error to log a contextual message","Inspect the raw os error code in the panic message to identify the specific filesystem problem"],"exampleFix":"// before\nlet builder = RegExpBuilder::from_file(\"data\"); // data is a directory\n// after\nlet path = Path::new(\"data/examples.txt\");\nassert!(path.is_file(), \"not a regular file: {}\", path.display());\nlet builder = RegExpBuilder::from_file(path);","handlingStrategy":"validation","validationCode":"let meta = std::fs::metadata(path)?;\nif !meta.is_file() { return Err(anyhow!(\"not a regular file: {}\", path.display())); }","typeGuard":null,"tryCatchPattern":"std::panic::catch_unwind(|| RegExpBuilder::from_file(path))\n    .map_err(|_| format!(\"failed to read {}: verify it is a readable regular file\", path.display()))","preventionTips":["Always verify the path is a regular file (not a directory or symlink loop) before reading","Avoid guessing error kinds yourself — do the io in your code and match on io::ErrorKind","Surface the raw os error code in your logs for diagnosis"],"tags":["panic","io","fallback"],"backgroundTag":"file-read-failed","analyzedSha":"99cc347707375e00514f938b76d885a201dfc110","analyzedAt":"2026-09-13T15:42:56.144Z","contentChangedAt":"2026-09-13T15:42:56.144Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}