diff --git a/ROADMAP.md b/ROADMAP.md index 001e409..af4a8bb 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,6 +1,7 @@ # Release 0.1 +- Print nice error in `cli/cmd/arg/download_limit.rs` +- Resolve panics with a nice error message - Panic when secret is missing from URL with info action -- Lowercase error messages - Switch to `directories` instead of `app_dirs2`? - Allow file/directory archiving on upload - Allow unarchiving on download diff --git a/api/src/action/delete.rs b/api/src/action/delete.rs index 0dd1447..28002c9 100644 --- a/api/src/action/delete.rs +++ b/api/src/action/delete.rs @@ -90,16 +90,16 @@ impl DeleteData { #[derive(Fail, Debug)] pub enum Error { /// An error occurred while preparing the action. - #[fail(display = "Failed to prepare the action")] + #[fail(display = "failed to prepare the action")] Prepare(#[cause] PrepareError), /// The given Send file has expired, or did never exist in the first place. /// Therefore the file could not be downloaded. - #[fail(display = "The file has expired or did never exist")] + #[fail(display = "the file has expired or did never exist")] Expired, /// An error has occurred while sending the filedeletion request. - #[fail(display = "Failed to send the file deletion request")] + #[fail(display = "failed to send the file deletion request")] Delete(#[cause] DeleteError), } @@ -136,23 +136,23 @@ pub enum DeleteDataError { #[derive(Fail, Debug)] pub enum PrepareError { /// Failed to authenticate - #[fail(display = "Failed to authenticate")] + #[fail(display = "failed to authenticate")] Auth(#[cause] NonceError), /// An error occurred while building the deletion data that will be /// send to the server. - #[fail(display = "Invalid parameters")] + #[fail(display = "invalid parameters")] DeleteData(#[cause] DeleteDataError), } #[derive(Fail, Debug)] pub enum DeleteError { /// Sending the file deletion request failed. - #[fail(display = "Failed to send file deletion request")] + #[fail(display = "failed to send file deletion request")] Request, /// The server responded with an error while requesting file deletion. - #[fail(display = "Bad response from server while deleting file")] + #[fail(display = "bad response from server while deleting file")] Response(#[cause] ResponseError), } diff --git a/api/src/action/download.rs b/api/src/action/download.rs index ebc5fe5..bf81c26 100644 --- a/api/src/action/download.rs +++ b/api/src/action/download.rs @@ -253,29 +253,29 @@ pub enum Error { /// An error occurred while fetching the metadata of the file. /// This step is required in order to succsessfully decrypt the /// file that will be downloaded. - #[fail(display = "Failed to fetch file metadata")] + #[fail(display = "failed to fetch file metadata")] Meta(#[cause] MetadataError), /// The given Send file has expired, or did never exist in the first place. /// Therefore the file could not be downloaded. - #[fail(display = "The file has expired or did never exist")] + #[fail(display = "the file has expired or did never exist")] Expired, /// A password is required, but was not given. - #[fail(display = "Missing password, password required")] + #[fail(display = "missing password, password required")] PasswordRequired, /// An error occurred while downloading the file. - #[fail(display = "Failed to download the file")] + #[fail(display = "failed to download the file")] Download(#[cause] DownloadError), /// An error occurred while decrypting the downloaded file. - #[fail(display = "Failed to decrypt the downloaded file")] + #[fail(display = "failed to decrypt the downloaded file")] Decrypt, /// An error occurred while opening or writing to the target file. // TODO: show what file this is about - #[fail(display = "Couldn't use the target file at '{}'", _0)] + #[fail(display = "couldn't use the target file at '{}'", _0)] File(String, #[cause] FileError), } @@ -299,46 +299,46 @@ impl From for Error { pub enum DownloadError { /// An error occurred while computing the cryptographic signature used for /// downloading the file. - #[fail(display = "Failed to compute cryptographic signature")] + #[fail(display = "failed to compute cryptographic signature")] ComputeSignature, /// Sending the request to download the file failed. - #[fail(display = "Failed to request file download")] + #[fail(display = "failed to request file download")] Request, /// The server responded with an error while requesting the file download. - #[fail(display = "Bad response from server while requesting download")] + #[fail(display = "bad response from server while requesting download")] Response(#[cause] ResponseError), /// The length of the file is missing, thus the length of the file to download /// couldn't be determined. - #[fail(display = "Couldn't determine file download length, missing property")] + #[fail(display = "couldn't determine file download length, missing property")] NoLength, /// Failed to start or update the downloading progress, because of this the /// download can't continue. - #[fail(display = "Failed to update download progress")] + #[fail(display = "failed to update download progress")] Progress, /// The actual download and decryption process the server. /// This covers reading the file from the server, decrypting the file, /// and writing it to the file system. - #[fail(display = "Failed to download the file")] + #[fail(display = "failed to download the file")] Download, /// Verifying the downloaded file failed. - #[fail(display = "File verification failed")] + #[fail(display = "file verification failed")] Verify, } #[derive(Fail, Debug)] pub enum FileError { /// An error occurred while creating or opening the file to write to. - #[fail(display = "Failed to create or replace the file")] + #[fail(display = "failed to create or replace the file")] Create(#[cause] IoError), /// Failed to create an encrypted writer for the file, which is used to /// decrypt the downloaded file. - #[fail(display = "Failed to create file decryptor")] + #[fail(display = "failed to create file decryptor")] EncryptedWriter, } diff --git a/api/src/action/exists.rs b/api/src/action/exists.rs index 9d3328a..f33746d 100644 --- a/api/src/action/exists.rs +++ b/api/src/action/exists.rs @@ -102,18 +102,18 @@ impl Default for ExistsResponse { #[derive(Fail, Debug)] pub enum Error { /// Sending the request to check whether the file exists failed. - #[fail(display = "Failed to send request whether the file exists")] + #[fail(display = "failed to send request whether the file exists")] Request, /// The server responded with an error while checking whether the file /// exists. - #[fail(display = "Bad response from server while checking file existence")] + #[fail(display = "bad response from server while checking file existence")] Response(#[cause] ResponseError), /// The response from the server when checking if the file exists was /// malformed. /// Maybe the server responded with a new format that isn't supported yet /// by this client. - #[fail(display = "Received malformed authentication nonce")] + #[fail(display = "received malformed authentication nonce")] Malformed, } diff --git a/api/src/action/info.rs b/api/src/action/info.rs index 5a803e7..24e24ea 100644 --- a/api/src/action/info.rs +++ b/api/src/action/info.rs @@ -139,16 +139,16 @@ impl InfoResponse { #[derive(Fail, Debug)] pub enum Error { /// An error occurred while preparing the action. - #[fail(display = "Failed to prepare the action")] + #[fail(display = "failed to prepare the action")] Prepare(#[cause] PrepareError), /// The given Send file has expired, or did never exist in the first place. /// Therefore the file could not be downloaded. - #[fail(display = "The file has expired or did never exist")] + #[fail(display = "the file has expired or did never exist")] Expired, /// An error has occurred while sending the info request to the server. - #[fail(display = "Failed to send the file info request")] + #[fail(display = "failed to send the file info request")] Info(#[cause] InfoError), } @@ -194,12 +194,12 @@ pub enum InfoDataError { #[derive(Fail, Debug)] pub enum PrepareError { /// Failed authenticating, needed to fetch the info - #[fail(display = "Failed to authenticate")] + #[fail(display = "failed to authenticate")] Auth(#[cause] NonceError), /// An error occurred while building the info data that will be /// send to the server. - #[fail(display = "Invalid parameters")] + #[fail(display = "invalid parameters")] InfoData(#[cause] InfoDataError), } @@ -212,15 +212,15 @@ impl From for PrepareError { #[derive(Fail, Debug)] pub enum InfoError { /// Sending the request to fetch the file info failed. - #[fail(display = "Failed to send file info request")] + #[fail(display = "failed to send file info request")] Request, /// The server responded with an error while fetching the file info. - #[fail(display = "Bad response from server while fetching file info")] + #[fail(display = "bad response from server while fetching file info")] Response(#[cause] ResponseError), /// Failed to decode the info response from the server. /// Maybe the server responded with data from a newer API version. - #[fail(display = "Failed to decode info response")] + #[fail(display = "failed to decode info response")] Decode(#[cause] ReqwestError), } diff --git a/api/src/action/metadata.rs b/api/src/action/metadata.rs index 668b3d8..b04dbac 100644 --- a/api/src/action/metadata.rs +++ b/api/src/action/metadata.rs @@ -231,22 +231,22 @@ impl<'a> MetadataResponse { pub enum Error { /// An error occurred while checking whether the file exists on the /// server. - #[fail(display = "Failed to check whether the file exists")] + #[fail(display = "failed to check whether the file exists")] Exists(#[cause] ExistsError), /// A general error occurred while requesting the file data. /// This may be because authentication failed, because decrypting the /// file metadata didn't succeed, or due to some other reason. - #[fail(display = "Failed to request file data")] + #[fail(display = "failed to request file data")] Request(#[cause] RequestError), /// The given Send file has expired, or did never exist in the first place. /// Therefore the file could not be downloaded. - #[fail(display = "The file has expired or did never exist")] + #[fail(display = "the file has expired or did never exist")] Expired, /// A password is required, but was not given. - #[fail(display = "Missing password, password required")] + #[fail(display = "missing password, password required")] PasswordRequired, } @@ -280,11 +280,11 @@ impl From for Error { #[derive(Fail, Debug)] pub enum RequestError { /// Failed authenticating, in order to fetch the file data. - #[fail(display = "Failed to authenticate")] + #[fail(display = "failed to authenticate")] Auth(#[cause] NonceError), /// Failed to retrieve the file metadata. - #[fail(display = "Failed to retrieve file metadata")] + #[fail(display = "failed to retrieve file metadata")] Meta(#[cause] MetaError), } @@ -292,28 +292,28 @@ pub enum RequestError { pub enum MetaError { /// An error occurred while computing the cryptographic signature used for /// decryption. - #[fail(display = "Failed to compute cryptographic signature")] + #[fail(display = "failed to compute cryptographic signature")] ComputeSignature, /// Sending the request to gather the metadata encryption nonce failed. - #[fail(display = "Failed to request metadata nonce")] + #[fail(display = "failed to request metadata nonce")] NonceRequest, /// The server responded with an error while fetching the metadata /// encryption nonce. - #[fail(display = "Bad response from server while fetching metadata nonce")] + #[fail(display = "bad response from server while fetching metadata nonce")] NonceResponse(#[cause] ResponseError), /// Couldn't parse the metadata encryption nonce. - #[fail(display = "Failed to parse the metadata encryption nonce")] + #[fail(display = "failed to parse the metadata encryption nonce")] Nonce(#[cause] NonceError), /// The received metadata is malformed, and couldn't be decoded or /// interpreted. - #[fail(display = "Received malformed metadata")] + #[fail(display = "received malformed metadata")] Malformed, /// Failed to decrypt the received metadata. - #[fail(display = "Failed to decrypt received metadata")] + #[fail(display = "failed to decrypt received metadata")] Decrypt, } diff --git a/api/src/action/params.rs b/api/src/action/params.rs index 6da2116..5a70022 100644 --- a/api/src/action/params.rs +++ b/api/src/action/params.rs @@ -162,17 +162,17 @@ impl Default for ParamsData { #[derive(Fail, Debug)] pub enum Error { /// An error occurred while preparing the action. - #[fail(display = "Failed to prepare setting the parameters")] + #[fail(display = "failed to prepare setting the parameters")] Prepare(#[cause] PrepareError), /// The given Send file has expired, or did never exist in the first place. /// Therefore the file could not be downloaded. - #[fail(display = "The file has expired or did never exist")] + #[fail(display = "the file has expired or did never exist")] Expired, /// An error has occurred while sending the parameter change request to /// the server. - #[fail(display = "Failed to send the parameter change request")] + #[fail(display = "failed to send the parameter change request")] Change(#[cause] ChangeError), } @@ -211,7 +211,7 @@ pub enum ParamsDataError { /// The number of downloads is invalid, as it was out of the allowed /// bounds. See `PARAMS_DOWNLOAD_MIN` and `PARAMS_DOWNLOAD_MAX`. // TODO: use bound values from constants, don't hardcode them here - #[fail(display = "Invalid number of downloads, must be between 1 and 20")] + #[fail(display = "invalid number of downloads, must be between 1 and 20")] DownloadBounds, /// Some error occurred while trying to wrap the parameter data in an @@ -224,12 +224,12 @@ pub enum ParamsDataError { #[derive(Fail, Debug)] pub enum PrepareError { /// Failed authenticating, needed to change the parameters. - #[fail(display = "Failed to authenticate")] + #[fail(display = "failed to authenticate")] Auth(#[cause] NonceError), /// An error occurred while building the parameter data that will be send /// to the server. - #[fail(display = "Invalid parameters")] + #[fail(display = "invalid parameters")] ParamsData(#[cause] ParamsDataError), } @@ -242,10 +242,10 @@ impl From for PrepareError { #[derive(Fail, Debug)] pub enum ChangeError { /// Sending the request to change the parameters failed. - #[fail(display = "Failed to send parameter change request")] + #[fail(display = "failed to send parameter change request")] Request, /// The server responded with an error while changing the file parameters. - #[fail(display = "Bad response from server while changing parameters")] + #[fail(display = "bad response from server while changing parameters")] Response(#[cause] ResponseError), } diff --git a/api/src/action/password.rs b/api/src/action/password.rs index 91e4589..98773c0 100644 --- a/api/src/action/password.rs +++ b/api/src/action/password.rs @@ -108,17 +108,17 @@ impl PasswordData { #[derive(Fail, Debug)] pub enum Error { /// An error occurred while preparing the action. - #[fail(display = "Failed to prepare setting the password")] + #[fail(display = "failed to prepare setting the password")] Prepare(#[cause] PrepareError), /// The given Send file has expired, or did never exist in the first place. /// Therefore the file could not be downloaded. - #[fail(display = "The file has expired or did never exist")] + #[fail(display = "the file has expired or did never exist")] Expired, /// An error has occurred while sending the password change request to /// the server. - #[fail(display = "Failed to send the password change request")] + #[fail(display = "failed to send the password change request")] Change(#[cause] ChangeError), } @@ -155,7 +155,7 @@ impl From for Error { #[derive(Fail, Debug)] pub enum PrepareError { /// Failed authenticating, needed to set a new password. - #[fail(display = "Failed to authenticate")] + #[fail(display = "failed to authenticate")] Auth(#[cause] NonceError), /// Some error occurred while building the data that will be sent. @@ -174,10 +174,10 @@ impl From for PrepareError { #[derive(Fail, Debug)] pub enum ChangeError { /// Sending the request to change the password failed. - #[fail(display = "Failed to send password change request")] + #[fail(display = "failed to send password change request")] Request, /// The server responded with an error while changing the file password. - #[fail(display = "Bad response from server while changing password")] + #[fail(display = "bad response from server while changing password")] Response(#[cause] ResponseError), } diff --git a/api/src/action/upload.rs b/api/src/action/upload.rs index f50c556..9d5cfab 100644 --- a/api/src/action/upload.rs +++ b/api/src/action/upload.rs @@ -355,7 +355,7 @@ impl<'a> FileData<'a> { #[derive(Fail, Debug)] pub enum Error { /// An error occurred while preparing a file for uploading. - #[fail(display = "Failed to prepare uploading the file")] + #[fail(display = "failed to prepare uploading the file")] Prepare(#[cause] PrepareError), /// An error occurred while opening, reading or using the file that @@ -365,15 +365,15 @@ pub enum Error { File(#[cause] FileError), /// An error occurred while uploading the file. - #[fail(display = "Failed to upload the file")] + #[fail(display = "failed to upload the file")] Upload(#[cause] UploadError), /// An error occurred while chaining file parameters. - #[fail(display = "Failed to change file parameters")] + #[fail(display = "failed to change file parameters")] Params(#[cause] ParamsError), /// An error occurred while setting the password. - #[fail(display = "Failed to set the password")] + #[fail(display = "failed to set the password")] Password(#[cause] PasswordError), } @@ -416,42 +416,42 @@ impl From for Error { #[derive(Fail, Debug)] pub enum PrepareError { /// Failed to prepare the file metadata for uploading. - #[fail(display = "Failed to prepare file metadata")] + #[fail(display = "failed to prepare file metadata")] Meta(#[cause] MetaError), /// Failed to create an encrypted file reader, that encrypts /// the file on the fly when it is read. - #[fail(display = "Failed to access the file to upload")] + #[fail(display = "failed to access the file to upload")] Reader(#[cause] ReaderError), } #[derive(Fail, Debug)] pub enum MetaError { /// An error occurred while encrypting the file metadata. - #[fail(display = "Failed to encrypt file metadata")] + #[fail(display = "failed to encrypt file metadata")] Encrypt, } #[derive(Fail, Debug)] pub enum ReaderError { /// An error occurred while creating the file encryptor. - #[fail(display = "Failed to create file encryptor")] + #[fail(display = "failed to create file encryptor")] Encrypt, /// Failed to create the progress reader, attached to the file reader, /// to measure the uploading progress. - #[fail(display = "Failed to create progress reader")] + #[fail(display = "failed to create progress reader")] Progress, } #[derive(Fail, Debug)] pub enum FileError { /// The given path, is not not a file or doesn't exist. - #[fail(display = "The given path is not an existing file")] + #[fail(display = "the given path is not an existing file")] NotAFile, /// Failed to open the file that must be uploaded for reading. - #[fail(display = "Failed to open the file to upload")] + #[fail(display = "failed to open the file to upload")] Open(#[cause] IoError), } @@ -459,24 +459,24 @@ pub enum FileError { pub enum UploadError { /// Failed to start or update the uploading progress, because of this the /// upload can't continue. - #[fail(display = "Failed to update upload progress")] + #[fail(display = "failed to update upload progress")] Progress, /// Sending the request to upload the file failed. - #[fail(display = "Failed to request file upload")] + #[fail(display = "failed to request file upload")] Request, /// The server responded with an error while uploading. - #[fail(display = "Bad response from server while uploading")] + #[fail(display = "bad response from server while uploading")] Response(#[cause] ResponseError), /// Failed to decode the upload response from the server. /// Maybe the server responded with data from a newer API version. - #[fail(display = "Failed to decode upload response")] + #[fail(display = "failed to decode upload response")] Decode(#[cause] ReqwestError), /// Failed to parse the retrieved URL from the upload response. - #[fail(display = "Failed to parse received URL")] + #[fail(display = "failed to parse received URL")] ParseUrl(#[cause] UrlParseError), } diff --git a/api/src/api/data.rs b/api/src/api/data.rs index f026221..3a67925 100644 --- a/api/src/api/data.rs +++ b/api/src/api/data.rs @@ -45,6 +45,6 @@ impl OwnedData #[derive(Debug, Fail)] pub enum Error { /// Missing owner token, which is required. - #[fail(display = "Missing owner token, must be specified")] + #[fail(display = "missing owner token, must be specified")] NoOwnerToken, } diff --git a/api/src/api/nonce.rs b/api/src/api/nonce.rs index cfb3a4a..ca2a60c 100644 --- a/api/src/api/nonce.rs +++ b/api/src/api/nonce.rs @@ -49,26 +49,26 @@ pub fn header_nonce(response: &Response) pub enum NonceError { /// Sending the request to fetch a nonce failed, /// as the file has expired or did never exist. - #[fail(display = "The file has expired or did never exist")] + #[fail(display = "the file has expired or did never exist")] Expired, /// Sending the request to fetch a nonce failed. - #[fail(display = "Failed to request encryption nonce")] + #[fail(display = "failed to request encryption nonce")] Request, /// The server responded with an error while requesting the encryption nonce, /// required for some operations. - #[fail(display = "Bad response from server while requesting encryption nonce")] + #[fail(display = "bad response from server while requesting encryption nonce")] Response(#[cause] ResponseError), /// The nonce header was missing from the request. - #[fail(display = "Missing nonce in server response")] + #[fail(display = "missing nonce in server response")] NoNonceHeader, /// The received nonce could not be parsed, because it was malformed. /// Maybe the server responded with a new format that isn't supported yet /// by this client. - #[fail(display = "Received malformed nonce")] + #[fail(display = "received malformed nonce")] MalformedNonce, } diff --git a/api/src/api/request.rs b/api/src/api/request.rs index 62b0cf1..97d0b97 100644 --- a/api/src/api/request.rs +++ b/api/src/api/request.rs @@ -30,15 +30,15 @@ pub fn ensure_success(response: &Response) -> Result<(), ResponseError> { #[derive(Fail, Debug)] pub enum ResponseError { /// This request lead to an expired file, or a file that never existed. - #[fail(display = "This file has expired or did never exist")] + #[fail(display = "this file has expired or did never exist")] Expired, /// We were unauthorized to make this request. /// This is usually because of an incorrect password. - #[fail(display = "Unauthorized, are the credentials correct?")] + #[fail(display = "unauthorized, are the credentials correct?")] Unauthorized, /// Some undefined error occurred with this response. - #[fail(display = "Bad HTTP response: {}", _1)] + #[fail(display = "bad HTTP response: {}", _1)] Other(StatusCode, String), } diff --git a/api/src/file/remote_file.rs b/api/src/file/remote_file.rs index cf7dcab..7b4f9c6 100644 --- a/api/src/file/remote_file.rs +++ b/api/src/file/remote_file.rs @@ -325,14 +325,14 @@ impl RemoteFile { #[derive(Debug, Fail)] pub enum FileParseError { /// An URL format error. - #[fail(display = "Failed to parse remote file, invalid URL format")] + #[fail(display = "failed to parse remote file, invalid URL format")] UrlFormatError(#[cause] UrlParseError), /// An error for an invalid share URL format. - #[fail(display = "Failed to parse remote file, invalid URL")] + #[fail(display = "failed to parse remote file, invalid URL")] InvalidUrl, /// An error for an invalid secret format, if an URL fragmet exists. - #[fail(display = "Failed to parse remote file, invalid secret in URL")] + #[fail(display = "failed to parse remote file, invalid secret in URL")] InvalidSecret, } diff --git a/api/src/reader.rs b/api/src/reader.rs index b55aada..7d49225 100644 --- a/api/src/reader.rs +++ b/api/src/reader.rs @@ -514,21 +514,6 @@ impl Write for EncryptedFileWriter { } } - - - - - - - - - - - - - - - /// A writer wrapper, that measures the reading process for a writer with a /// known length. /// diff --git a/cli/src/action/delete.rs b/cli/src/action/delete.rs index b8c1d82..538869d 100644 --- a/cli/src/action/delete.rs +++ b/cli/src/action/delete.rs @@ -73,15 +73,15 @@ impl<'a> Delete<'a> { pub enum Error { /// Failed to parse a share URL, it was invalid. /// This error is not related to a specific action. - #[fail(display = "Invalid share URL")] + #[fail(display = "invalid share URL")] InvalidUrl(#[cause] FileParseError), /// Could not delete, the file has expired or did never exist. - #[fail(display = "The file has expired or did never exist")] + #[fail(display = "the file has expired or did never exist")] Expired, /// An error occurred while deleting the remote file. - #[fail(display = "Failed to delete the shared file")] + #[fail(display = "failed to delete the shared file")] Delete(#[cause] DeleteError), } diff --git a/cli/src/action/download.rs b/cli/src/action/download.rs index 9625a13..652a862 100644 --- a/cli/src/action/download.rs +++ b/cli/src/action/download.rs @@ -172,12 +172,12 @@ impl<'a> Download<'a> { // Create the parent directories if let Err(err) = create_dir_all(parent) { quit_error(err.context( - "Failed to create parent directories for output file", + "failed to create parent directories for output file", ), ErrorHints::default()); } }, None => quit_error_msg( - "Invalid output file path", + "invalid output file path", ErrorHints::default(), ), } @@ -198,7 +198,7 @@ impl<'a> Download<'a> { match target.canonicalize() { Ok(target) => return target, Err(err) => quit_error( - err.context("Failed to canonicalize target path"), + err.context("failed to canonicalize target path"), ErrorHints::default(), ), } @@ -209,7 +209,7 @@ impl<'a> Download<'a> { match target.canonicalize() { Ok(target) => return target.join(name_hint), Err(err) => quit_error( - err.context("Failed to canonicalize target path"), + err.context("failed to canonicalize target path"), ErrorHints::default(), ), } @@ -228,7 +228,7 @@ impl<'a> Download<'a> { match current_dir() { Ok(target) => return target.join(name_hint), Err(err) => quit_error(err.context( - "Failed to determine working directory to use for the output file" + "failed to determine working directory to use for the output file" ), ErrorHints::default()), } } @@ -247,7 +247,7 @@ impl<'a> Download<'a> { match current_dir() { Ok(workdir) => target = workdir.join(target), Err(err) => quit_error(err.context( - "Failed to determine working directory to use for the output file" + "failed to determine working directory to use for the output file" ), ErrorHints::default()), } } @@ -260,15 +260,15 @@ impl<'a> Download<'a> { pub enum Error { /// Failed to parse a share URL, it was invalid. /// This error is not related to a specific action. - #[fail(display = "Invalid share URL")] + #[fail(display = "invalid share URL")] InvalidUrl(#[cause] FileParseError), /// An error occurred while checking if the file exists. - #[fail(display = "Failed to check whether the file exists")] + #[fail(display = "failed to check whether the file exists")] Exists(#[cause] ExistsError), /// An error occurred while fetching metadata. - #[fail(display = "Failed to fetch file metadata")] + #[fail(display = "failed to fetch file metadata")] Metadata(#[cause] MetadataError), /// An error occurred while downloading the file. @@ -276,7 +276,7 @@ pub enum Error { Download(#[cause] DownloadError), /// The given Send file has expired, or did never exist in the first place. - #[fail(display = "The file has expired or did never exist")] + #[fail(display = "the file has expired or did never exist")] Expired, } diff --git a/cli/src/action/exists.rs b/cli/src/action/exists.rs index 93d44f1..f028533 100644 --- a/cli/src/action/exists.rs +++ b/cli/src/action/exists.rs @@ -72,11 +72,11 @@ impl<'a> Exists<'a> { pub enum Error { /// Failed to parse a share URL, it was invalid. /// This error is not related to a specific action. - #[fail(display = "Invalid share URL")] + #[fail(display = "invalid share URL")] InvalidUrl(#[cause] FileParseError), /// An error occurred while checking if the file exists. - #[fail(display = "Failed to check whether the file exists")] + #[fail(display = "failed to check whether the file exists")] Exists(#[cause] ExistsError), } diff --git a/cli/src/action/history.rs b/cli/src/action/history.rs index cfd9e08..e929ba8 100644 --- a/cli/src/action/history.rs +++ b/cli/src/action/history.rs @@ -43,7 +43,7 @@ impl<'a> History<'a> { // Get the history path, make sure it exists let history_path = matcher_main.history(); if !history_path.is_file() { - println!("No files in history"); + eprintln!("No files in history"); return Ok(()); } @@ -52,7 +52,7 @@ impl<'a> History<'a> { // Do not report any files if there aren't any if history.files().is_empty() { - println!("No files in history"); + eprintln!("No files in history"); return Ok(()); } diff --git a/cli/src/action/info.rs b/cli/src/action/info.rs index 3e5f013..29d6258 100644 --- a/cli/src/action/info.rs +++ b/cli/src/action/info.rs @@ -83,7 +83,7 @@ impl<'a> Info<'a> { let metadata = ApiMetadata::new(&file, password, false) .invoke(&client) .map_err(|err| print_error(err.context( - "Failed to fetch file metadata, showing limited info", + "failed to fetch file metadata, showing limited info", ))) .ok(); @@ -124,19 +124,19 @@ impl<'a> Info<'a> { pub enum Error { /// Failed to parse a share URL, it was invalid. /// This error is not related to a specific action. - #[fail(display = "Invalid share URL")] + #[fail(display = "invalid share URL")] InvalidUrl(#[cause] FileParseError), /// An error occurred while checking if the file exists. - #[fail(display = "Failed to check whether the file exists")] + #[fail(display = "failed to check whether the file exists")] Exists(#[cause] ExistsError), /// An error occurred while fetching the file information. - #[fail(display = "Failed to fetch file info")] + #[fail(display = "failed to fetch file info")] Info(#[cause] InfoError), /// The given Send file has expired, or did never exist in the first place. - #[fail(display = "The file has expired or did never exist")] + #[fail(display = "the file has expired or did never exist")] Expired, } diff --git a/cli/src/action/upload.rs b/cli/src/action/upload.rs index d8f22ed..b9718da 100644 --- a/cli/src/action/upload.rs +++ b/cli/src/action/upload.rs @@ -61,7 +61,7 @@ impl<'a> Upload<'a> { // The file is too large, show an error and quit quit_error_msg( format!( - "The file size is {}, bigger than the maximum allowed of {}", + "the file size is {}, bigger than the maximum allowed of {}", format_bytes(size), format_bytes(UPLOAD_SIZE_MAX), ), @@ -74,7 +74,7 @@ impl<'a> Upload<'a> { } else if size > UPLOAD_SIZE_MAX_RECOMMENDED && !matcher_main.force() { // The file is larger than the recommended maximum, warn eprintln!( - "The file size is {}, bigger than the recommended maximum of {}", + "the file size is {}, bigger than the recommended maximum of {}", format_bytes(size), format_bytes(UPLOAD_SIZE_MAX_RECOMMENDED), ); @@ -86,7 +86,7 @@ impl<'a> Upload<'a> { } } } else { - print_error_msg("Failed to check the file size, ignoring"); + print_error_msg("failed to check the file size, ignoring"); } // Create a reqwest client @@ -132,7 +132,7 @@ impl<'a> Upload<'a> { if matcher_upload.open() { if let Err(err) = open_url(url.clone()) { print_error( - err.context("Failed to open the URL in the browser") + err.context("failed to open the URL in the browser") ); }; } @@ -143,7 +143,7 @@ impl<'a> Upload<'a> { if matcher_upload.copy() { if set_clipboard(url.as_str().to_owned()).is_err() { print_error( - err_msg("Failed to copy the URL to the clipboard") + err_msg("failed to copy the URL to the clipboard") .compat() ); } diff --git a/cli/src/cmd/arg/download_limit.rs b/cli/src/cmd/arg/download_limit.rs index 19cc6bd..c30ac3c 100644 --- a/cli/src/cmd/arg/download_limit.rs +++ b/cli/src/cmd/arg/download_limit.rs @@ -41,6 +41,7 @@ impl<'a> CmdArgOption<'a> for ArgDownloadLimit { .map(|d| d.parse::().expect("invalid download limit")) .and_then(|d| { // Check the download limit bounds + // TODO: print a nicely formatted error here if d < DOWNLOAD_MIN || d > DOWNLOAD_MAX { panic!( "invalid download limit, must be between {} and {}", diff --git a/cli/src/cmd/arg/host.rs b/cli/src/cmd/arg/host.rs index 3d88174..425ee4f 100644 --- a/cli/src/cmd/arg/host.rs +++ b/cli/src/cmd/arg/host.rs @@ -37,7 +37,7 @@ impl<'a> CmdArgOption<'a> for ArgHost { match parse_host(&url) { Ok(url) => url, Err(err) => quit_error( - err.context("Failed to parse the given host"), + err.context("failed to parse the given host"), ErrorHints::default(), ), } diff --git a/cli/src/cmd/arg/url.rs b/cli/src/cmd/arg/url.rs index 95f6a44..47bf192 100644 --- a/cli/src/cmd/arg/url.rs +++ b/cli/src/cmd/arg/url.rs @@ -33,7 +33,7 @@ impl<'a> CmdArgOption<'a> for ArgUrl { match parse_host(&url) { Ok(url) => url, Err(err) => quit_error( - err.context("Failed to parse the given share URL"), + err.context("failed to parse the given share URL"), ErrorHints::default(), ), } diff --git a/cli/src/cmd/matcher/main.rs b/cli/src/cmd/matcher/main.rs index 4db19bb..1dc4c7b 100644 --- a/cli/src/cmd/matcher/main.rs +++ b/cli/src/cmd/matcher/main.rs @@ -36,7 +36,7 @@ impl<'a: 'b, 'b> MainMatcher<'a> { match path { Some(path) => path, None => quit_error_msg( - "History file path not set", + "history file path not set", ErrorHintsBuilder::default() .history(true) .verbose(false) diff --git a/cli/src/error.rs b/cli/src/error.rs index e8d0fb4..92598d7 100644 --- a/cli/src/error.rs +++ b/cli/src/error.rs @@ -37,41 +37,41 @@ impl From for Error { #[derive(Debug, Fail)] pub enum ActionError { /// An error occurred while invoking the delete action. - #[fail(display = "Failed to delete the file")] + #[fail(display = "failed to delete the file")] Delete(#[cause] DeleteError), /// An error occurred while invoking the download action. - #[fail(display = "Failed to download the requested file")] + #[fail(display = "failed to download the requested file")] Download(#[cause] CliDownloadError), /// An error occurred while invoking the exists action. - #[fail(display = "Failed to check whether the file exists")] + #[fail(display = "failed to check whether the file exists")] Exists(#[cause] ExistsError), /// An error occurred while processing the file history. - #[fail(display = "Failed to process the history")] + #[fail(display = "failed to process the history")] History(#[cause] CliHistoryError), /// An error occurred while invoking the info action. - #[fail(display = "Failed to fetch file info")] + #[fail(display = "failed to fetch file info")] Info(#[cause] CliInfoError), /// An error occurred while invoking the params action. - #[fail(display = "Failed to change the parameters")] + #[fail(display = "failed to change the parameters")] Params(#[cause] ParamsError), /// An error occurred while invoking the password action. - #[fail(display = "Failed to change the password")] + #[fail(display = "failed to change the password")] Password(#[cause] PasswordError), /// An error occurred while invoking the upload action. // TODO: bind the upload cause here - #[fail(display = "Failed to upload the specified file")] + #[fail(display = "failed to upload the specified file")] Upload(#[cause] UploadError), /// Failed to parse a share URL, it was invalid. /// This error is not related to a specific action. - #[fail(display = "Invalid share URL")] + #[fail(display = "invalid share URL")] InvalidUrl(#[cause] FileParseError), } diff --git a/cli/src/history.rs b/cli/src/history.rs index 3123056..273b71f 100644 --- a/cli/src/history.rs +++ b/cli/src/history.rs @@ -74,9 +74,9 @@ impl History { let version = history.version.as_ref().unwrap(); if let Ok(true) = VersionCompare::compare_to(version, VERSION_MIN, &CompOp::Lt) { - print_warning("History file version is too old, ignoring"); + print_warning("history file version is too old, ignoring"); } else if let Ok(true) = VersionCompare::compare_to(version, VERSION_MAX, &CompOp::Gt) { - print_warning("History file has an unknown version, ignoring"); + print_warning("history file has an unknown version, ignoring"); } } @@ -244,7 +244,7 @@ impl Drop for History { // Save and report errors if let Err(err) = self.save() { print_error( - err.context("Failed to auto save history, ignoring"), + err.context("failed to auto save history, ignoring"), ); } } @@ -265,11 +265,11 @@ impl Default for History { #[derive(Debug, Fail)] pub enum Error { /// An error occurred while loading the history from a file. - #[fail(display = "Failed to load history from file")] + #[fail(display = "failed to load history from file")] Load(#[cause] LoadError), /// An error occurred while saving the history to a file. - #[fail(display = "Failed to save history to file")] + #[fail(display = "failed to save history to file")] Save(#[cause] SaveError), } @@ -311,20 +311,20 @@ impl From for LoadError { #[derive(Debug, Fail)] pub enum SaveError { /// No autosave file path was present, failed to save. - #[fail(display = "No autosave file path specified")] + #[fail(display = "no autosave file path specified")] NoPath, /// Failed to serialize the history for saving. - #[fail(display = "Failed to serialize the history for saving")] + #[fail(display = "failed to serialize the history for saving")] Serialize(#[cause] SerError), /// Failed to write to the history file. - #[fail(display = "Failed to write to the history file")] + #[fail(display = "failed to write to the history file")] Write(#[cause] IoError), /// Failed to delete the history file, which was tried because there /// are no history items to save. - #[fail(display = "Failed to delete history file, because history is empty")] + #[fail(display = "failed to delete history file, because history is empty")] Delete(#[cause] IoError), } diff --git a/cli/src/history_tool.rs b/cli/src/history_tool.rs index 7109634..b72a191 100644 --- a/cli/src/history_tool.rs +++ b/cli/src/history_tool.rs @@ -42,7 +42,7 @@ fn add_error(matcher_main: &MainMatcher, file: RemoteFile, overwrite: bool) pub fn add(matcher_main: &MainMatcher, file: RemoteFile, overwrite: bool) { if let Err(err) = add_error(matcher_main, file, overwrite) { print_error(err.context( - "Failed to add file to local history, ignoring", + "failed to add file to local history, ignoring", )); } } @@ -73,7 +73,7 @@ pub fn remove(matcher_main: &MainMatcher, file: &RemoteFile) -> bool { let ok = result.is_ok(); if let Err(err) = result { print_error(err.context( - "Failed to remove file from local history, ignoring", + "failed to remove file from local history, ignoring", )); } ok @@ -109,7 +109,7 @@ pub fn derive_owner_token(matcher_main: &MainMatcher, file: &mut RemoteFile) -> Ok(history) => history, Err(err) => { print_error(err.context( - "Failed to derive file owner token from history, ignoring", + "failed to derive file owner token from history, ignoring", )); return false; } diff --git a/cli/src/host.rs b/cli/src/host.rs index 37eda0c..0cd37e6 100644 --- a/cli/src/host.rs +++ b/cli/src/host.rs @@ -26,34 +26,34 @@ pub fn parse_host(host: &str) -> Result { #[derive(Debug, Fail)] pub enum HostError { /// The URL scheme is missing or invalid. - #[fail(display = "The URL must have the 'https://' or 'http://' scheme")] + #[fail(display = "the URL must have the 'https://' or 'http://' scheme")] Scheme, /// The host address is empty. - #[fail(display = "Empty host address")] + #[fail(display = "empty host address")] Empty, /// The port number is invalid. - #[fail(display = "Invalid port")] + #[fail(display = "invalid port")] Port, /// The given IPv4 styled address is invalid. - #[fail(display = "Invalid IPv4 address in the host")] + #[fail(display = "invalid IPv4 address in the host")] Ipv4, /// The given IPv6 styled address is invalid. - #[fail(display = "Invalid IPv6 address in the host")] + #[fail(display = "invalid IPv6 address in the host")] Ipv6, /// The domain contains an invalid character. - #[fail(display = "Invalid character in the domain")] + #[fail(display = "invalid character in the domain")] DomainCharacter, /// The base host is missing from the host URL. - #[fail(display = "Missing host in the host URL")] + #[fail(display = "missing host in the host URL")] NoBase, /// Failed to parse the host URL due to another reason. - #[fail(display = "Could not parse host URL")] + #[fail(display = "could not parse host URL")] Other(#[cause] ParseError), } diff --git a/cli/src/util.rs b/cli/src/util.rs index 2faaf89..c89eee6 100644 --- a/cli/src/util.rs +++ b/cli/src/util.rs @@ -49,7 +49,7 @@ pub fn print_error(err: E) { // Fall back to a basic message if count == 0 { - eprintln!("{} {}", highlight_error("error:"), "An undefined error occurred"); + eprintln!("{} {}", highlight_error("error:"), "an undefined error occurred"); } } @@ -250,7 +250,7 @@ pub fn set_clipboard(content: String) -> Result<(), Box> { pub fn check_empty_password(password: &str, matcher_main: &MainMatcher) { if !matcher_main.force() && password.is_empty() { quit_error_msg( - "An empty password is not supported by the web interface", + "an empty password is not supported by the web interface", ErrorHintsBuilder::default() .force(true) .verbose(false) @@ -267,7 +267,7 @@ pub fn prompt_password(main_matcher: &MainMatcher) -> String { // Quit with an error if we may not interact if main_matcher.no_interact() { quit_error_msg( - "Missing password, must be specified in no-interact mode", + "missing password, must be specified in no-interact mode", ErrorHintsBuilder::default() .password(true) .verbose(false) @@ -280,7 +280,7 @@ pub fn prompt_password(main_matcher: &MainMatcher) -> String { match prompt_password_stderr("Password: ") { Ok(password) => password, Err(err) => quit_error(err.context( - "Failed to read password from password prompt" + "failed to read password from password prompt" ), ErrorHints::default()), } } @@ -319,7 +319,7 @@ pub fn prompt(msg: &str, main_matcher: &MainMatcher) -> String { // Quit with an error if we may not interact if main_matcher.no_interact() { quit_error_msg(format!( - "Could not prompt for '{}' in no-interact mode, maybe specify it", + "could not prompt for '{}' in no-interact mode, maybe specify it", msg, ), ErrorHints::default()); } @@ -332,7 +332,7 @@ pub fn prompt(msg: &str, main_matcher: &MainMatcher) -> String { let mut input = String::new(); if let Err(err) = stdin().read_line(&mut input) { quit_error(err.context( - "Failed to read input from prompt" + "failed to read input from prompt" ), ErrorHints::default()); } @@ -376,7 +376,7 @@ pub fn prompt_yes( return def; } else { quit_error_msg(format!( - "Could not prompt question '{}' in no-interact mode, maybe specify it", + "could not prompt question '{}' in no-interact mode, maybe specify it", msg, ), ErrorHints::default()); } @@ -451,7 +451,7 @@ pub fn ensure_owner_token( *token = Some(prompt_owner_token(main_matcher)); } else { quit_error_msg( - "Missing owner token, must be specified in no-interact mode", + "missing owner token, must be specified in no-interact mode", ErrorHintsBuilder::default() .owner(true) .verbose(false) @@ -546,19 +546,20 @@ pub fn exe_name() -> String { .unwrap_or(crate_name!().into()) } -/// Check whether there is enough space avaialble at the given `path` to store a file -/// with the given `size`. +/// Ensure that there is enough free disk space available at the given `path`, +/// to store a file with the given `size`. /// /// If an error occurred while querying the file system, -/// the error is reported to the user, and `true` is returned. +/// the error is reported to the user and the method returns. /// -/// `false` is only returned when sure that there isn't enough space available. +/// If there is not enough disk space available, +/// an error is reported and the program will quit. pub fn ensure_enough_space>(path: P, size: u64) { // Get the available space at this path let space = match available_space(path) { Ok(space) => space, Err(err) => { - print_error(err.context("Failed to check available space on disk, ignoring")); + print_error(err.context("failed to check available space on disk, ignoring")); return; }, }; @@ -570,15 +571,15 @@ pub fn ensure_enough_space>(path: P, size: u64) { // Create an info message giving details about the required space let info = format!( - "{} is required, but only {} is available", + "{} of space required, but only {} is available", format_bytes(size), format_bytes(space), ); // Print an descriptive error and quit quit_error( - err_msg("Not enough disk space available in the target directory") - .context("Failed to download file"), + err_msg("not enough disk space available in the target directory") + .context("failed to download file"), ErrorHintsBuilder::default() .add_info(info) .force(true)