Merge pull request #3810 from ethcore/defaults-parse-fix

Tolerate errors in user_defaults
This commit is contained in:
Gav Wood 2016-12-11 15:15:43 +01:00 committed by GitHub
commit e6444cd106

View File

@ -128,7 +128,13 @@ impl Default for UserDefaults {
impl UserDefaults { impl UserDefaults {
pub fn load<P>(path: P) -> Result<Self, String> where P: AsRef<Path> { pub fn load<P>(path: P) -> Result<Self, String> where P: AsRef<Path> {
match File::open(path) { match File::open(path) {
Ok(file) => from_reader(file).map_err(|e| e.to_string()), Ok(file) => match from_reader(file) {
Ok(defaults) => Ok(defaults),
Err(e) => {
warn!("Error loading user defaults file: {:?}", e);
Ok(UserDefaults::default())
},
},
_ => Ok(UserDefaults::default()), _ => Ok(UserDefaults::default()),
} }
} }