[pbs-devel] [PATCH proxmox-backup v2] api2/tape/restore: restore_snapshot_archive: only ignore tape errors

Dietmar Maurer dietmar at proxmox.com
Wed Apr 14 10:51:24 CEST 2021


> Now, while this is not happening a lot for the `Other` case, it does
> happen quite a few times for the `Disk` case, so you could also add a
> few little helpers for some "quality of life" improvements:
> 
>     impl RestoreError {
>         fn other<T: ToString>(err: T) -> Self {
>             RestoreError::Other(err.to_string())
>         }
> 
>         fn disk<T: ToString>(err: T) -> Self {
>             RestoreError::Disk(err.to_string())
>         }
> 
>         fn tape<T: Into<Error>>(err: T) -> Self {
>             RestoreError::Tape(err.into())
>         }
>     }

I like that idea, but I don't think it is a good idea to convert Errors to strings.
So I would use:

#[derive(thiserror::Error, Debug)]
pub enum RestoreError {
    #[error("tape error: {0}")]
    Tape(Error),
    #[error("disk error: {0}")]
    Disk(Error),
    #[error("{0}")]
    Other(Error),
}





More information about the pbs-devel mailing list