1- use crate :: error :: { ProxyError , Result } ;
1+ use anyhow :: { Context , Result } ;
22use keyring:: Entry ;
33use serde:: { Deserialize , Serialize } ;
44
@@ -19,23 +19,23 @@ impl DeploymentConfig {
1919
2020 match keyring. get_password ( ) {
2121 Ok ( config_json) => serde_json:: from_str ( & config_json)
22- . map_err ( |e| ProxyError :: Config ( format ! ( "Failed to parse config: {}" , e ) ) ) ,
22+ . with_context ( || "Failed to parse config" ) ,
2323 Err ( keyring:: Error :: NoEntry ) => {
2424 // If no config exists, create it interactively
2525 let config = Self :: create_interactive ( ) ?;
2626 config. save ( ) ?;
2727 Ok ( config)
2828 }
29- Err ( e) => Err ( e. into ( ) ) ,
29+ Err ( e) => Err ( e) . with_context ( || "Failed to access keyring" ) ,
3030 }
3131 }
3232
3333 pub fn save ( & self ) -> Result < ( ) > {
3434 let keyring = Entry :: new ( Self :: SERVICE_NAME , Self :: USERNAME ) ?;
3535 let config_json = serde_json:: to_string ( self )
36- . map_err ( |e| ProxyError :: Config ( format ! ( "Failed to serialize config: {}" , e ) ) ) ?;
37- keyring. set_password ( & config_json) ? ;
38- Ok ( ( ) )
36+ . with_context ( || "Failed to serialize config" ) ?;
37+ keyring. set_password ( & config_json)
38+ . with_context ( || "Failed to save config to keyring" )
3939 }
4040
4141 fn create_interactive ( ) -> Result < Self > {
0 commit comments