Browse Source

Use err!() instead of panic!() for unrecognised DATABASE_URL

Follow the established codebase convention where configuration
validation errors use err!() to propagate gracefully, rather than
panic!(). The error propagates through from_config() and is caught
by create_db_pool() which logs and calls exit(1).
pull/7061/head
mfw78 2 weeks ago
committed by mfw78
parent
commit
44d79406b7
  1. 4
      src/db/mod.rs

4
src/db/mod.rs

@ -288,12 +288,12 @@ impl DbConnType {
if std::path::Path::new(url).exists() { if std::path::Path::new(url).exists() {
return Ok(DbConnType::Sqlite); return Ok(DbConnType::Sqlite);
} }
panic!( err!(format!(
"`DATABASE_URL` does not match any known database scheme (mysql://, postgresql://, sqlite://) \ "`DATABASE_URL` does not match any known database scheme (mysql://, postgresql://, sqlite://) \
and no existing SQLite database was found at '{url}'. \ and no existing SQLite database was found at '{url}'. \
If you intend to use SQLite, use an explicit `sqlite://` prefix in your `DATABASE_URL`. \ If you intend to use SQLite, use an explicit `sqlite://` prefix in your `DATABASE_URL`. \
Otherwise, check your DATABASE_URL for typos or quoting issues." Otherwise, check your DATABASE_URL for typos or quoting issues."
); ))
} }
#[cfg(not(sqlite))] #[cfg(not(sqlite))]

Loading…
Cancel
Save