From ab0d8cb9aa107c8d561f3c188e6cbf472a7df23b Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Tue, 13 Jun 2017 02:21:46 -0700 Subject: :shirt: Fix clippy warnings --- src/error.rs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs index 92709c2..6b567a2 100644 --- a/src/error.rs +++ b/src/error.rs @@ -43,13 +43,31 @@ pub enum ConfigError { PathParse(nom::ErrorKind), /// Configuration could not be parsed from file. - FileParse { uri: Option, cause: Box }, + FileParse { + /// The URI used to access the file (if not loaded from a string). + /// Example: `/path/to/config.json` + uri: Option, + + /// The captured error from attempting to parse the file in its desired format. + /// This is the actual error object from the library used for the parsing. + cause: Box + }, /// Value could not be converted into the requested type. Type { + /// The URI that references the source that the value came from. + /// Example: `/path/to/config.json` or `Environment` or `etcd://localhost` + // TODO: Why is this called Origin but FileParse has a uri field? origin: Option, + + /// What we found when parsing the value unexpected: Unexpected, + + /// What was expected when parsing the value expected: &'static str, + + /// The key in the configuration hash of this value (if available where the + /// error is generated). key: Option, }, @@ -153,8 +171,7 @@ impl Error for ConfigError { ConfigError::Frozen => "configuration is frozen", ConfigError::NotFound(_) => "configuration property not found", ConfigError::Type { .. } => "invalid type", - ConfigError::Foreign(ref cause) => cause.description(), - ConfigError::FileParse { ref cause, .. } => cause.description(), + ConfigError::Foreign(ref cause) | ConfigError::FileParse { ref cause, .. } => cause.description(), ConfigError::PathParse(ref kind) => kind.description(), _ => "configuration error", @@ -163,8 +180,7 @@ impl Error for ConfigError { fn cause(&self) -> Option<&Error> { match *self { - ConfigError::Foreign(ref cause) => Some(cause.as_ref()), - ConfigError::FileParse { ref cause, .. } => Some(cause.as_ref()), + ConfigError::Foreign(ref cause) | ConfigError::FileParse { ref cause, .. } => Some(cause.as_ref()), _ => None } -- cgit v1.2.3