Marco Ricci commited on 2024-08-16 12:48:10
              Zeige 1 geänderte Dateien mit 24 Einfügungen und 1 Löschungen.
            
These errors have already been passed through, but they were neither documented nor explicitly handled in the command-line interface with an appropriate error message.
| ... | ... | 
                      @@ -157,6 +157,12 @@ def _get_suitable_ssh_keys(  | 
                  
| 157 | 157 | 
                        passphrase derivation.  | 
                    
| 158 | 158 | 
                         | 
                    
| 159 | 159 | 
                        Raises:  | 
                    
| 160 | 
                        + KeyError:  | 
                    |
| 161 | 
                        + `conn` was `None`, and the `SSH_AUTH_SOCK` environment  | 
                    |
| 162 | 
                        + variable was not found.  | 
                    |
| 163 | 
                        + OSError:  | 
                    |
| 164 | 
                        + `conn` was a socket or `None`, and there was an error  | 
                    |
| 165 | 
                        + setting up a socket connection to the agent.  | 
                    |
| 160 | 166 | 
                        LookupError:  | 
                    
| 161 | 167 | 
                        No keys usable for passphrase derivation are loaded into the  | 
                    
| 162 | 168 | 
                        SSH agent.  | 
                    
| ... | ... | 
                      @@ -188,7 +194,7 @@ def _get_suitable_ssh_keys(  | 
                  
| 188 | 194 | 
                        if vault.Vault._is_suitable_ssh_key(key): # noqa: SLF001  | 
                    
| 189 | 195 | 
                        yield pair  | 
                    
| 190 | 196 | 
                        if not suitable_keys: # pragma: no cover  | 
                    
| 191 | 
                        - raise IndexError(_NO_USABLE_KEYS)  | 
                    |
| 197 | 
                        + raise LookupError(_NO_USABLE_KEYS)  | 
                    |
| 192 | 198 | 
                         | 
                    
| 193 | 199 | 
                         | 
                    
| 194 | 200 | 
                        def _prompt_for_selection(  | 
                    
| ... | ... | 
                      @@ -290,6 +296,12 @@ def _select_ssh_key(  | 
                  
| 290 | 296 | 
                        The selected SSH key.  | 
                    
| 291 | 297 | 
                         | 
                    
| 292 | 298 | 
                        Raises:  | 
                    
| 299 | 
                        + KeyError:  | 
                    |
| 300 | 
                        + `conn` was `None`, and the `SSH_AUTH_SOCK` environment  | 
                    |
| 301 | 
                        + variable was not found.  | 
                    |
| 302 | 
                        + OSError:  | 
                    |
| 303 | 
                        + `conn` was a socket or `None`, and there was an error  | 
                    |
| 304 | 
                        + setting up a socket connection to the agent.  | 
                    |
| 293 | 305 | 
                        IndexError:  | 
                    
| 294 | 306 | 
                        The user made an invalid or empty selection, or requested an  | 
                    
| 295 | 307 | 
                        abort.  | 
                    
| ... | ... | 
                      @@ -854,12 +866,16 @@ def derivepassphrase(  | 
                  
| 854 | 866 | 
                        return _load_config()  | 
                    
| 855 | 867 | 
                        except FileNotFoundError:  | 
                    
| 856 | 868 | 
                                     return {'services': {}}
                       | 
                    
| 869 | 
                        + except OSError as e:  | 
                    |
| 870 | 
                        +            err(f'Cannot load config: {e.strerror}: {e.filename!r}')
                       | 
                    |
| 857 | 871 | 
                        except Exception as e: # noqa: BLE001  | 
                    
| 858 | 872 | 
                                     err(f'Cannot load config: {e}')
                       | 
                    
| 859 | 873 | 
                         | 
                    
| 860 | 874 | 
                        def put_config(config: _types.VaultConfig, /) -> None:  | 
                    
| 861 | 875 | 
                        try:  | 
                    
| 862 | 876 | 
                        _save_config(config)  | 
                    
| 877 | 
                        + except OSError as exc:  | 
                    |
| 878 | 
                        +            err(f'Cannot store config: {exc.strerror}: {exc.filename!r}')
                       | 
                    |
| 863 | 879 | 
                        except Exception as exc: # noqa: BLE001  | 
                    
| 864 | 880 | 
                                     err(f'Cannot store config: {exc}')
                       | 
                    
| 865 | 881 | 
                         | 
                    
| ... | ... | 
                      @@ -1013,6 +1029,13 @@ def derivepassphrase(  | 
                  
| 1013 | 1029 | 
                        )  | 
                    
| 1014 | 1030 | 
                        except IndexError:  | 
                    
| 1015 | 1031 | 
                                         err('no valid SSH key selected')
                       | 
                    
| 1032 | 
                        + except KeyError:  | 
                    |
| 1033 | 
                        +                err('cannot find running SSH agent; check SSH_AUTH_SOCK')
                       | 
                    |
| 1034 | 
                        + except OSError as e:  | 
                    |
| 1035 | 
                        + err(  | 
                    |
| 1036 | 
                        +                    f'Cannot connect to SSH agent: {e.strerror}: '
                       | 
                    |
| 1037 | 
                        +                    f'{e.filename!r}'
                       | 
                    |
| 1038 | 
                        + )  | 
                    |
| 1016 | 1039 | 
                        except (LookupError, RuntimeError) as e:  | 
                    
| 1017 | 1040 | 
                        err(str(e))  | 
                    
| 1018 | 1041 | 
                        elif use_phrase:  | 
                    
| 1019 | 1042 |