mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-25 11:12:48 +03:00
Cleanup
This commit is contained in:
parent
fb4e5ee8e1
commit
2f1e5acec4
@ -2,6 +2,7 @@ use crate::errors::{InitError, MainFileError, ManifestError, SourceDirectoryErro
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
pub enum CLIError {
|
||||
|
||||
#[fail(display = "{}: {}", _0, _1)]
|
||||
Crate(&'static str, String),
|
||||
|
||||
@ -16,6 +17,7 @@ pub enum CLIError {
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
SourceDirectoryError(SourceDirectoryError),
|
||||
|
||||
}
|
||||
|
||||
impl From<InitError> for CLIError {
|
||||
|
@ -2,8 +2,20 @@ use std::io;
|
||||
|
||||
#[derive(Debug, Fail)]
|
||||
pub enum MainFileError {
|
||||
|
||||
#[fail(display = "{}: {}", _0, _1)]
|
||||
Crate(&'static str, String),
|
||||
|
||||
#[fail(display = "creating: {}", _0)]
|
||||
Creating(io::Error),
|
||||
|
||||
#[fail(display = "writing: {}", _0)]
|
||||
Writing(io::Error),
|
||||
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for MainFileError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
MainFileError::Crate("std::io", format!("{}", error))
|
||||
}
|
||||
}
|
||||
|
@ -40,9 +40,8 @@ impl MainFile {
|
||||
path.push(PathBuf::from(FILE_NAME_DEFAULT));
|
||||
}
|
||||
|
||||
let mut file = File::create(&path).map_err(MainFileError::Creating)?;
|
||||
file.write_all(self.template().as_bytes())
|
||||
.map_err(MainFileError::Writing)
|
||||
let mut file = File::create(&path)?;
|
||||
Ok(file.write_all(self.template().as_bytes())?)
|
||||
}
|
||||
|
||||
fn template(&self) -> String {
|
||||
|
Loading…
Reference in New Issue
Block a user