Minor updates to Paul's comments.

- Bubbled up home_dir not found error
 - Made comment show up in docs
This commit is contained in:
Luke Anderson 2019-03-13 13:38:28 +11:00
parent e942d7533b
commit b000a0972e
No known key found for this signature in database
GPG Key ID: 44408169EC61E228

View File

@ -21,7 +21,8 @@ impl ClientConfig {
/// Build a new configuration from defaults.
pub fn default() -> Result<Self, Error> {
let data_dir = {
let home = dirs::home_dir().expect("Unable to determine home dir.");
let home = dirs::home_dir()
.ok_or(Error::new(ErrorKind::NotFound, "Unable to determine home directory."))?;
home.join(DEFAULT_LIGHTHOUSE_DIR)
};
fs::create_dir_all(&data_dir)?;
@ -39,7 +40,7 @@ impl ClientConfig {
})
}
// Try to load keys from datadir, or fail
/// Try to load keys from key_dir, returning None if none are found or an error.
pub fn fetch_keys(&self) -> Result<Option<Vec<Keypair>>, Error> {
let mut key_files = fs::read_dir(&self.key_dir)?.peekable();