Browse Source

Error handling 🤷‍♂️

master
Dylan Baker 6 years ago
parent
commit
a73746be3f
1 changed files with 11 additions and 0 deletions
  1. 11
    0
      src/main.rs

+ 11
- 0
src/main.rs View File

78
 
78
 
79
 fn main() {
79
 fn main() {
80
     let cwd = env::current_dir().expect("Couldn't read current directory");
80
     let cwd = env::current_dir().expect("Couldn't read current directory");
81
+
82
+    match fs::create_dir(cwd.join("public")) {
83
+        Ok(_) => {},
84
+        Err(err) => {
85
+            match err.kind() {
86
+                std::io::ErrorKind::AlreadyExists => {},
87
+                _ => panic!(err)
88
+            }
89
+        }
90
+    }
91
+
81
     let layout = fs::read_to_string(&cwd.join("templates").join("layout.html"))
92
     let layout = fs::read_to_string(&cwd.join("templates").join("layout.html"))
82
         .expect("Couldn't find layout template");
93
         .expect("Couldn't find layout template");
83
     let post_paths = read_posts_dir(&cwd.join("posts"));
94
     let post_paths = read_posts_dir(&cwd.join("posts"));

Loading…
Cancel
Save