Skip to content

Commit

Permalink
feat: better errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrutchf committed Nov 28, 2024
1 parent c3f55c4 commit 334a73b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/subcommands/main_subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,12 @@ impl MainSubcommand {

let file_station = self.file_station.clone().context("File Station should not be null.")?;

// Check if folder exists

let path_parts = configuration.path.split('/');
let name = path_parts.last().context("Our path should have a name")?;
// We remove one extra character so that we don't have a trailing '/'.
let folder_path_string = configuration.path[..(configuration.path.len() - name.len() - 1)].to_string();
let folder_path = folder_path_string.as_str();
let _folders = file_station.create_folder(folder_path, name, false).await?;
let _folders = file_station.create_folder(folder_path, name, true).await?;

Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions src/synology_api/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ pub enum SynologyStatusCode {

#[derive(Error, Debug)]
pub enum SynologyErrorStatus {
#[error("Error occurred on Synology.")]
#[error(transparent)]
ServerError(#[from] SynologyStatusCode),
#[error("HTTP error occurred.")]
HttpError(StatusCode),
#[error("Reqwest threw an error.")]
#[error(transparent)]
ReqwestError(#[from] reqwest::Error),
#[error("Serde threw an error.")]
#[error(transparent)]
SerdeError(#[from] serde_json::Error),
#[error("TOTP required but not provided")]
NoTotp,
Expand Down

0 comments on commit 334a73b

Please sign in to comment.