Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error treatment calling todo!() and crashing in non-exhaustive match. #29

Closed
marcospb19 opened this issue May 22, 2021 · 4 comments · Fixed by #147
Closed

Fix error treatment calling todo!() and crashing in non-exhaustive match. #29

marcospb19 opened this issue May 22, 2021 · 4 comments · Fixed by #147
Labels
bug Something isn't working high priority
Milestone

Comments

@marcospb19
Copy link
Member

No description provided.

@GabrielSimonetto
Copy link
Collaborator

GabrielSimonetto commented Oct 3, 2021

This issue is regarding the impl fmt::Display for Error on error.rs

            Error::OofError(err) => FinalError::with_title(err),
            Error::IoError { reason } => FinalError::with_title(reason),
           ...
            _err => {
                todo!();
            }

TODO display messages:

  • - UnknownExtensionError(String)
  • - MissingExtensionError(PathBuf)
  • - IoError { reason: String }
  • - FileNotFound(PathBuf)
  • - AlreadyExists
  • - InvalidZipArchive(&'static str)
  • - PermissionDenied
  • - UnsupportedZipArchive(&'static str)
  • - InternalError
  • - OofError(oof::OofError)
  • - CompressingRootFolder
  • - MissingArgumentsForCompression
  • - CompressionTypo
  • - WalkdirError { reason: String }

It would be neat to tackle this as soon as possible because dropping the wildcard match forces us to add the error messages as soon as a new error enum is created, and as is, the pile could just grow forever unattended 🍍

@marcospb19
Copy link
Member Author

marcospb19 commented Oct 3, 2021

Wow, nice checklist.

This is a priority, however, this issue is blocked by #56, that one needs to be resolved first.

That's because a lot of the work necessary to solve this issue would have to be discarded and remade after #56, because fs-err will change our error messages.

@marcospb19 marcospb19 added bug Something isn't working enhancement New feature or request waiting for another issue There is another issue that needs to be resolved earlier and removed enhancement New feature or request waiting for another issue There is another issue that needs to be resolved earlier labels Oct 3, 2021
@marcospb19 marcospb19 added this to the 0.2.1 milestone Oct 7, 2021
@marcospb19 marcospb19 changed the title Fix error treatment calling todo!() and crash in non-exhaustive match. Fix error treatment calling todo!() and crashing in non-exhaustive match. Oct 15, 2021
@GabrielSimonetto GabrielSimonetto removed the waiting for another issue There is another issue that needs to be resolved earlier label Oct 30, 2021
@GabrielSimonetto
Copy link
Collaborator

#56 is solved so this is not blocked anymore d:

@GabrielSimonetto
Copy link
Collaborator

I will paste here a way to trigger one of the untreated errors, since it might be useful to someone, the error in particular is the NotFound

impl From<std::io::Error> for Error {
    fn from(err: std::io::Error) -> Self {
        match err.kind() {
            std::io::ErrorKind::NotFound => todo!(),

Currently this error just panics:

thread 'main' panicked at 'not yet implemented', src/error.rs:161:45
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The way to trigger it is to delete the file you are trying to decompress after the program has checked that it exists, you can do that inserting a sleep after the command check:

        Subcommand::Decompress { files, output: output_folder } => {
            std::thread::sleep(std::time::Duration::from_secs(10));

Then, while it sleeps you remove the zip that you are working with

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants