Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Add message to IO errors (#10324)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pzixel authored and ordian committed Feb 18, 2019
1 parent aea289e commit ca67dc2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions parity/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ use journaldb::Algorithm;

#[derive(Debug)]
pub enum Error {
CannotCreateConfigPath,
CannotWriteVersionFile,
CannotUpdateVersionFile,
CannotCreateConfigPath(io::Error),
CannotWriteVersionFile(io::Error),
CannotUpdateVersionFile(io::Error),
SemVer(SemVerError),
}

Expand Down Expand Up @@ -105,7 +105,7 @@ fn with_locked_version<F>(db_path: &str, script: F) -> Result<usize, Error>
where F: Fn(&Version) -> Result<usize, Error>
{
let mut path = PathBuf::from(db_path);
create_dir_all(&path).map_err(|_| Error::CannotCreateConfigPath)?;
create_dir_all(&path).map_err(Error::CannotCreateConfigPath)?;
path.push("ver.lock");

let version =
Expand All @@ -118,11 +118,11 @@ fn with_locked_version<F>(db_path: &str, script: F) -> Result<usize, Error>
})
.unwrap_or(Version::new(0, 9, 0));

let mut lock = File::create(&path).map_err(|_| Error::CannotWriteVersionFile)?;
let mut lock = File::create(&path).map_err(Error::CannotWriteVersionFile)?;
let result = script(&version);

let written_version = Version::parse(CURRENT_VERSION)?;
lock.write_all(written_version.to_string().as_bytes()).map_err(|_| Error::CannotUpdateVersionFile)?;
lock.write_all(written_version.to_string().as_bytes()).map_err(Error::CannotUpdateVersionFile)?;
result
}

Expand Down

0 comments on commit ca67dc2

Please sign in to comment.