mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
Store: error handling for file errors (#3364)
Use existing error handling plumbing for Store file creation errors Co-authored-by: Nym Seddon <unseddd@shh.xyz>
This commit is contained in:
parent
20b4500625
commit
39ca5d1c11
1 changed files with 9 additions and 2 deletions
|
@ -47,6 +47,9 @@ pub enum Error {
|
|||
/// Wraps a serialization error for Writeable or Readable
|
||||
#[fail(display = "Serialization Error")]
|
||||
SerErr(String),
|
||||
/// File handling error
|
||||
#[fail(display = "File handling Error")]
|
||||
FileErr(String),
|
||||
/// Other error
|
||||
#[fail(display = "Other Error")]
|
||||
OtherErr(String),
|
||||
|
@ -102,8 +105,12 @@ impl Store {
|
|||
None => "lmdb".to_owned(),
|
||||
};
|
||||
let full_path = [root_path.to_owned(), name].join("/");
|
||||
fs::create_dir_all(&full_path)
|
||||
.expect("Unable to create directory 'db_root' to store chain_data");
|
||||
fs::create_dir_all(&full_path).map_err(|e| {
|
||||
Error::FileErr(format!(
|
||||
"Unable to create directory 'db_root' to store chain_data: {:?}",
|
||||
e
|
||||
))
|
||||
})?;
|
||||
|
||||
let mut env_builder = lmdb::EnvBuilder::new()?;
|
||||
env_builder.set_maxdbs(8)?;
|
||||
|
|
Loading…
Reference in a new issue