mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 08:51: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
|
/// Wraps a serialization error for Writeable or Readable
|
||||||
#[fail(display = "Serialization Error")]
|
#[fail(display = "Serialization Error")]
|
||||||
SerErr(String),
|
SerErr(String),
|
||||||
|
/// File handling error
|
||||||
|
#[fail(display = "File handling Error")]
|
||||||
|
FileErr(String),
|
||||||
/// Other error
|
/// Other error
|
||||||
#[fail(display = "Other Error")]
|
#[fail(display = "Other Error")]
|
||||||
OtherErr(String),
|
OtherErr(String),
|
||||||
|
@ -102,8 +105,12 @@ impl Store {
|
||||||
None => "lmdb".to_owned(),
|
None => "lmdb".to_owned(),
|
||||||
};
|
};
|
||||||
let full_path = [root_path.to_owned(), name].join("/");
|
let full_path = [root_path.to_owned(), name].join("/");
|
||||||
fs::create_dir_all(&full_path)
|
fs::create_dir_all(&full_path).map_err(|e| {
|
||||||
.expect("Unable to create directory 'db_root' to store chain_data");
|
Error::FileErr(format!(
|
||||||
|
"Unable to create directory 'db_root' to store chain_data: {:?}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})?;
|
||||||
|
|
||||||
let mut env_builder = lmdb::EnvBuilder::new()?;
|
let mut env_builder = lmdb::EnvBuilder::new()?;
|
||||||
env_builder.set_maxdbs(8)?;
|
env_builder.set_maxdbs(8)?;
|
||||||
|
|
Loading…
Reference in a new issue