Improve error messages for not finding LBA sources
This commit is contained in:
@@ -184,11 +184,18 @@ pub fn input_to_vec(input: Input) -> Result<Vec<u8>, Error> {
|
||||
|
||||
pub fn read_file(file_path: &PathBuf) -> Result<Vec<u8>, Error> {
|
||||
match std::fs::read(file_path) {
|
||||
Ok(data) => {
|
||||
Ok(data)
|
||||
},
|
||||
Err(error) => {
|
||||
Err(Error::from_text(format!("Failed reading file {} with error: \"{}\"", file_path.display(), error)))
|
||||
}
|
||||
Ok(data) => Ok(data),
|
||||
Err(error) => create_file_read_error(file_path, error),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_file_to_string(file_path: &PathBuf) -> Result<String, Error> {
|
||||
match std::fs::read_to_string(file_path) {
|
||||
Ok(string) => Ok(string),
|
||||
Err(error) => create_file_read_error(file_path, error),
|
||||
}
|
||||
}
|
||||
|
||||
fn create_file_read_error<T>(file_path: &PathBuf, error: std::io::Error) -> Result<T, Error> {
|
||||
Err(Error::from_text(format!("Failed reading file {} with error: \"{}\"", file_path.display(), error)))
|
||||
}
|
Reference in New Issue
Block a user