Add an error management in db module
[recipes.git] / backend / src / main.rs
index 0376507..daeed7a 100644 (file)
@@ -39,7 +39,6 @@ async fn home_page(req: HttpRequest) -> impl Responder {
 
 #[get("/recipe/view/{id}")]
 async fn view_page(req: HttpRequest, path: web::Path<(i32,)>) -> impl Responder {
-    panic!("ERROR");
     ViewRecipeTemplate { recipes: vec![ db::Recipe { title: String::from("Saumon en croûte feuilletée"), id: 1 }, db::Recipe { title: String::from("Croissant au jambon"), id: 2 } ], current_recipe: db::Recipe { title: String::from("Saumon en croûte feuilletée"), id: 1 } }
 }
 
@@ -108,7 +107,10 @@ fn process_args() -> bool {
         print_usage();
         return true
     } else if args.iter().any(|arg| arg == "--test") {
-        let db_connection = db::Connection::new();
+        match db::Connection::new() {
+            Ok(_) => (),
+            Err(error) => println!("Error: {:?}", error)
+        }
         return true
     }