mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-29 21:00:54 +00:00
feat(config): better errors for mislabeled fields
This commit is contained in:
parent
c2b9f87e31
commit
d9fc4899ad
@ -3,7 +3,7 @@
|
||||
#[cfg_attr(
|
||||
feature = "sqlx-toml",
|
||||
derive(serde::Deserialize),
|
||||
serde(default, rename_all = "kebab-case")
|
||||
serde(default, rename_all = "kebab-case", deny_unknown_fields)
|
||||
)]
|
||||
pub struct Config {
|
||||
/// Override the database URL environment variable.
|
||||
|
||||
@ -5,7 +5,7 @@ use std::collections::BTreeMap;
|
||||
#[cfg_attr(
|
||||
feature = "sqlx-toml",
|
||||
derive(serde::Deserialize),
|
||||
serde(default, rename_all = "kebab-case")
|
||||
serde(default, rename_all = "kebab-case", deny_unknown_fields)
|
||||
)]
|
||||
pub struct Config {
|
||||
/// Specify which crates' types to use when types from multiple crates apply.
|
||||
|
||||
@ -16,7 +16,7 @@ use std::collections::BTreeSet;
|
||||
#[cfg_attr(
|
||||
feature = "sqlx-toml",
|
||||
derive(serde::Deserialize),
|
||||
serde(default, rename_all = "kebab-case")
|
||||
serde(default, rename_all = "kebab-case", deny_unknown_fields)
|
||||
)]
|
||||
pub struct Config {
|
||||
/// Specify the names of schemas to create if they don't already exist.
|
||||
|
||||
@ -48,7 +48,7 @@ mod tests;
|
||||
#[cfg_attr(
|
||||
feature = "sqlx-toml",
|
||||
derive(serde::Deserialize),
|
||||
serde(default, rename_all = "kebab-case")
|
||||
serde(default, rename_all = "kebab-case", deny_unknown_fields)
|
||||
)]
|
||||
pub struct Config {
|
||||
/// Configuration shared by multiple components.
|
||||
@ -210,6 +210,9 @@ impl Config {
|
||||
// Only returned if the file exists but the feature is not enabled.
|
||||
panic!("{e}")
|
||||
}
|
||||
Err(ConfigError::Parse { error, path }) => {
|
||||
panic!("error parsing sqlx config {path:?}: {error}")
|
||||
}
|
||||
Err(e) => {
|
||||
panic!("failed to read sqlx config: {e}")
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user