refactor: panic on an unsuccessful .env load on a database connection
This commit is contained in:
		| @@ -4,9 +4,9 @@ use dotenvy::dotenv; | ||||
| use std::env; | ||||
|  | ||||
| pub(crate) fn establish_database_connection() -> ConnectionResult<PgConnection> { | ||||
|     dotenv().ok(); | ||||
|     dotenv().expect("Could not load environment variables."); | ||||
|  | ||||
|     let database_url = | ||||
|         env::var("DATABASE_URL").expect("The environment variable DATABASE_URL must be set."); | ||||
|         env::var("DATABASE_URL").expect("The environment variable DATABASE_URL has to be set."); | ||||
|     PgConnection::establish(&database_url) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user