diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2023-04-16 16:56:10 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2023-04-16 16:56:10 +0200 |
| commit | 48ea90800c3aa6055247fe2c56bc8e9d63024bd3 (patch) | |
| tree | ba1b23c685c5e894f88752a1f5e55a3def9582c7 /src/file_handler | |
| parent | 0e3bcda2ce1ba4bff5d457e48a82db6e6289aad6 (diff) | |
Handle layout error better
Diffstat (limited to 'src/file_handler')
| -rw-r--r-- | src/file_handler/mod.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/file_handler/mod.rs b/src/file_handler/mod.rs index a106c27..4932ef1 100644 --- a/src/file_handler/mod.rs +++ b/src/file_handler/mod.rs @@ -35,18 +35,18 @@ impl FileHandler { FileType::Unknown } - pub fn get_layout_or_panic(&mut self, files: &Vec<File>) { + pub fn get_layout_or_panic(&mut self, files: &Vec<File>) -> Result<(), &str> { for file in files { match file.file_type { FileType::Layout => { let layout_text = read_to_string(&file.path).unwrap(); self.layout = Some(layout_text); - return; + return Ok(()); }, _ => {} } } - panic!("No layout found. Please ensure there's a _layout.html file at the root"); + Err("No layout found. Please ensure there's a _layout.html file at the root") } pub fn handle_all(&self, source: &PathBuf, destination: &PathBuf, files: &Vec<File>) { |