mirror of
https://github.com/facebook/sapling.git
synced 2024-12-25 14:05:00 +03:00
edenapi: include field names in malformed config errors
Summary: Include the name of bad config fields in the error message so the user can more easily fix the problem. Reviewed By: quark-zju Differential Revision: D22591871 fbshipit-source-id: e23e2c71e49e0458e7ea5c13e7feac3a990ead0c
This commit is contained in:
parent
50a8016efc
commit
6f2adbf2cc
@ -41,7 +41,7 @@ impl Builder {
|
|||||||
pub fn from_config(config: &ConfigSet) -> Result<Self, EdenApiError> {
|
pub fn from_config(config: &ConfigSet) -> Result<Self, EdenApiError> {
|
||||||
let server_url = config
|
let server_url = config
|
||||||
.get_opt::<String>("edenapi", "url")
|
.get_opt::<String>("edenapi", "url")
|
||||||
.map_err(ConfigError::Malformed)?
|
.map_err(|e| ConfigError::Malformed("edenapi.url".into(), e))?
|
||||||
.ok_or(ConfigError::MissingUrl)?
|
.ok_or(ConfigError::MissingUrl)?
|
||||||
.parse::<Url>()
|
.parse::<Url>()
|
||||||
.map_err(ConfigError::InvalidUrl)?;
|
.map_err(ConfigError::InvalidUrl)?;
|
||||||
@ -53,15 +53,15 @@ impl Builder {
|
|||||||
|
|
||||||
let max_files = config
|
let max_files = config
|
||||||
.get_opt("edenapi", "maxfiles")
|
.get_opt("edenapi", "maxfiles")
|
||||||
.map_err(ConfigError::Malformed)?;
|
.map_err(|e| ConfigError::Malformed("edenapi.maxfiles".into(), e))?;
|
||||||
|
|
||||||
let max_trees = config
|
let max_trees = config
|
||||||
.get_opt("edenapi", "maxtrees")
|
.get_opt("edenapi", "maxtrees")
|
||||||
.map_err(ConfigError::Malformed)?;
|
.map_err(|e| ConfigError::Malformed("edenapi.maxtrees".into(), e))?;
|
||||||
|
|
||||||
let max_history = config
|
let max_history = config
|
||||||
.get_opt("edenapi", "maxhistory")
|
.get_opt("edenapi", "maxhistory")
|
||||||
.map_err(ConfigError::Malformed)?;
|
.map_err(|e| ConfigError::Malformed("edenapi.maxhistory".into(), e))?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
server_url: Some(server_url),
|
server_url: Some(server_url),
|
||||||
|
@ -33,6 +33,6 @@ pub enum ConfigError {
|
|||||||
MissingUrl,
|
MissingUrl,
|
||||||
#[error("Invalid server URL: {0}")]
|
#[error("Invalid server URL: {0}")]
|
||||||
InvalidUrl(#[source] url::ParseError),
|
InvalidUrl(#[source] url::ParseError),
|
||||||
#[error("Config value is malformed: {0}")]
|
#[error("Config field '{0}' is malformed")]
|
||||||
Malformed(#[source] anyhow::Error),
|
Malformed(String, #[source] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user