File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change 11use  crate :: { api:: { ApiState ,  RestError } ,  config:: Config } ; 
22use  axum:: { extract:: State ,  Json } ; 
3+ use  anyhow:: { anyhow,  Error } ; 
34
45#[ derive( serde:: Serialize ) ]  
56pub  struct  ChainConfigSummary  { 
@@ -10,12 +11,10 @@ pub struct ChainConfigSummary {
1011    pub  fee :  u128 , 
1112} 
1213
13- pub  async  fn  get_chain_configs ( State ( _state) :  State < ApiState > )  -> Result < Json < Vec < ChainConfigSummary > > ,  RestError >  { 
14+ pub  async  fn  get_chain_configs ( State ( _state) :  State < ApiState > )  -> Result < Json < Vec < ChainConfigSummary > > ,  Error >  { 
1415    // Try to load the config file (assume default path for now) 
15-     let  config = match  Config :: load ( "config.yaml" )  { 
16-         Ok ( cfg)  => cfg, 
17-         Err ( _)  => return  Err ( RestError :: Unknown ) , 
18-     } ; 
16+     let  yaml_content = std:: fs:: read_to_string ( "../config.yaml" ) . map_err ( |e| anyhow ! ( "Failed to read config file: {}" ,  e) ) ?; 
17+     let  config:  Config  = serde_yaml:: from_str ( & yaml_content) . map_err ( |e| anyhow ! ( "Failed to parse config file: {}" ,  e) ) ?; 
1918    let  mut  configs = Vec :: new ( ) ; 
2019    for  ( name,  chain)  in  config. chains . iter ( )  { 
2120        configs. push ( ChainConfigSummary  { 
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ pub async fn run_api(
8585
8686pub  async  fn  run ( opts :  & RunOptions )  -> Result < ( ) >  { 
8787    // Load environment variables from a .env file if present 
88-     let  _ = dotenv:: dotenv ( ) ?; 
88+     let  _ = dotenv:: dotenv ( ) . map_err ( |e|  anyhow ! ( "Failed to load .env file: {}" ,  e ) ) ?; 
8989    let  config = Config :: load ( & opts. config . config ) ?; 
9090    let  secret = config. provider . secret . load ( ) ?. ok_or ( anyhow ! ( 
9191        "Please specify a provider secret in the config file." 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments