rustic-rs / rustic_core

rustic_core - library for fast, encrypted, deduplicated backups that powers rustic-rs
https://rustic.cli.rs/ecosystem/rustic-core/
Apache License 2.0
31 stars 13 forks source link

Remove unnecessary `unwrap`/`expect` from codebase and improve error handling #140

Open simonsan opened 7 months ago

simonsan commented 7 months ago

There are still a lot of instances of unwrap/expect within the code base of rustic_core.

We should activate the clippy lints: #![deny(clippy::expect_used)] and #![deny(clippy::unwrap_used)] and tackle this issue. If we want to use rustic_core for GUI and other things, it shouldn't panic in circumstances that we can fix with good error handling.

CC: https://github.com/rustic-rs/rustic/issues/981

simonsan commented 6 months ago

Hetzner Storage Box via RClone:

"name" = "rustic-rs"
"operating_system" = "Windows 10.0.22631 (Windows 11 Professional) [64-bit]"
"crate_version" = "0.7.0-dev"
"explanation" = '''
Panic occurred in file 'C:\Users\dailyuse\.cargo\git\checkouts\rustic_core-fa42f42e094d79df\07c75ed\crates\core\src\commands\check.rs' at line 124
'''
"cause" = """
called `Result::unwrap()` on an `Err` value: backoff failed: Permanent(reqwest::Error { kind: Status(404), url: Url { scheme: \"http\", cannot_be_a_base: false, username: \"\", password: None, host: Some(Ipv4(127.0.0.1)), port: Some(61858), path: \"/data/f67d10627edb832163973a7afa4dcd3c5ecb97bdd80bafe1cdf45a589b1816c5\", query: None, fragment: None } })

Caused by:
    HTTP status client error (404 Not Found) for url (http://127.0.0.1:61858/data/f67d10627edb832163973a7afa4dcd3c5ecb97bdd80bafe1cdf45a589b1816c5)"""
"method" = "Panic"
"backtrace" = """

   0: 0x7ff74988d803 - <unresolved>
   1: 0x7ff7495528f9 - <unresolved>
   2: 0x7ff749552f21 - <unresolved>
   3: 0x7ff74989e319 - <unresolved>
   4: 0x7ff7490c9b03 - <unresolved>
   5: 0x7ff7490c9764 - <unresolved>
   6: 0x7ff74977205b - <unresolved>
   7: 0x7ffa9bc2257d - BaseThreadInitThunk
   8: 0x7ffa9d32aa58 - RtlUserThreadStart"""