We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c0401b1 commit f4ef5c5Copy full SHA for f4ef5c5
src/db/mod.rs
@@ -7,6 +7,7 @@ pub use self::delete_crate::delete_crate;
7
pub use self::file::{add_path_into_database, move_to_s3};
8
pub use self::migrate::migrate;
9
10
+use failure::Fail;
11
use postgres::error::Error;
12
use postgres::{Connection, TlsMode};
13
use std::env;
@@ -19,8 +20,8 @@ mod migrate;
19
20
21
/// Connects to database
22
pub fn connect_db() -> Result<Connection, failure::Error> {
- // FIXME: unwrap might not be the best here
23
- let db_url = env::var("CRATESFYI_DATABASE_URL")?;
+ let err = "CRATESFYI_DATABASE_URL environment variable is not set";
24
+ let db_url = env::var("CRATESFYI_DATABASE_URL").map_err(|e| e.context(err))?;
25
Connection::connect(&db_url[..], TlsMode::None).map_err(Into::into)
26
}
27
0 commit comments