Skip to content

Commit

Permalink
feat(#9): error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed Jun 5, 2024
1 parent 72e0472 commit 4bc3d1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

use crate::xml::storage::init;
use crate::xml::storage::touch_storage;

mod xml;

fn main() {
init();
touch_storage();
println!("Hello, world!");
}
15 changes: 13 additions & 2 deletions src/xml/storage.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::fmt::Error;
// The MIT License (MIT)
//
// Copyright (c) 2024 Aliaksei Bialiauski
Expand Down Expand Up @@ -26,14 +27,24 @@ use log::info;
pub fn touch_storage() {
let path = "fakehub.xml";
info!("Initializing XML storage: {path}");
File::create(path).unwrap();
info!("'{path}' initialized.");
let creating = File::create(path);
let _ = match creating {
Ok(file) => {
info!("'{path}' initialized");
Ok::<File, Error>(file)
}
Err(err) => {
panic!("fakehub storage failed to initialize in '{path}': {err}");
}
};
}


#[cfg(test)]
mod tests {
use std::fs;
use std::path::Path;

use crate::xml::storage::touch_storage;

fn clean() {
Expand Down

0 comments on commit 4bc3d1b

Please sign in to comment.