Print the path in file usage errors

This commit is contained in:
timvisee 2018-03-28 00:25:28 +02:00
parent 8ae79c3e4f
commit ae3bf27d0e
No known key found for this signature in database
GPG key ID: 109CBA0BF74036C2

View file

@ -61,8 +61,9 @@ impl<'a> Download<'a> {
// Open the file we will write to // Open the file we will write to
// TODO: this should become a temporary file first // TODO: this should become a temporary file first
// TODO: use the uploaded file name as default // TODO: use the uploaded file name as default
let out = File::create("downloaded.zip") let path = "downloaded.zip";
.map_err(|err| Error::File(FileError::Create(err)))?; let out = File::create(path)
.map_err(|err| Error::File(path.into(), FileError::Create(err)))?;
// Create the file reader for downloading // Create the file reader for downloading
let (reader, len) = self.create_file_reader(&key, meta_nonce, &client) let (reader, len) = self.create_file_reader(&key, meta_nonce, &client)
@ -74,7 +75,7 @@ impl<'a> Download<'a> {
len, len,
&key, &key,
reporter.clone(), reporter.clone(),
).map_err(|err| Error::File(err))?; ).map_err(|err| Error::File(path.into(), err))?;
// Download the file // Download the file
self.download(reader, writer, len, reporter) self.download(reader, writer, len, reporter)
@ -361,8 +362,8 @@ pub enum Error {
/// An error occurred while opening or writing to the target file. /// An error occurred while opening or writing to the target file.
// TODO: show what file this is about // TODO: show what file this is about
#[fail(display = "Couldn't use the target file")] #[fail(display = "Couldn't use the target file at '{}'", _0)]
File(#[cause] FileError), File(String, #[cause] FileError),
} }
impl From<AuthError> for Error { impl From<AuthError> for Error {