summaryrefslogtreecommitdiffstats
path: root/src/error.rs
diff options
context:
space:
mode:
authorRyan Leckey <ryan@launchbadge.com>2017-06-13 02:21:46 -0700
committerRyan Leckey <ryan@launchbadge.com>2017-06-13 02:21:46 -0700
commitab0d8cb9aa107c8d561f3c188e6cbf472a7df23b (patch)
tree80545ea4305763bbf47a9bd33f4da99d6c9b985b /src/error.rs
parentbabd49242c04e783ae27ea159e2bc42d24490520 (diff)
:shirt: Fix clippy warnings
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs26
1 files changed, 21 insertions, 5 deletions
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<String>, cause: Box<Error> },
+ FileParse {
+ /// The URI used to access the file (if not loaded from a string).
+ /// Example: `/path/to/config.json`
+ uri: Option<String>,
+
+ /// 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<Error>
+ },
/// 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<String>,
+
+ /// 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<String>,
},
@@ -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
}