File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ pub enum ServiceError {
1414 ) ]
1515 NoWriteAccess ,
1616 #[ error( "{0}" ) ]
17+ InvalidConfig ( String ) ,
18+ #[ error( "{0}" ) ]
1719 FromString ( String ) ,
1820 #[ error( "{0}" ) ]
1921 TransportError ( #[ from] TransportError ) ,
Original file line number Diff line number Diff line change @@ -18,20 +18,22 @@ pub struct FileSystemService {
1818
1919impl FileSystemService {
2020 pub fn try_new ( allowed_directories : & [ String ] ) -> ServiceResult < Self > {
21- let normalized_dirs: Vec < PathBuf > = allowed_directories
21+ let normalized_dirs: ServiceResult < Vec < PathBuf > > = allowed_directories
2222 . iter ( )
2323 . map ( fix_dockerhub_mcp_registry_gateway)
24- . map_while ( |dir| {
24+ . map ( |dir| {
2525 let expand_result = expand_home ( dir. into ( ) ) ;
2626 if !expand_result. is_dir ( ) {
27- panic ! ( "{}" , format!( "Error: {dir} is not a directory" ) ) ;
27+ return Err ( ServiceError :: InvalidConfig ( format ! (
28+ "Error: The path `{dir}` is not a valid directory. Please double-check your server configuration to ensure the directory exists and is accessible."
29+ ) ) ) ;
2830 }
29- Some ( expand_result)
31+ Ok ( expand_result)
3032 } )
3133 . collect ( ) ;
3234
3335 Ok ( Self {
34- allowed_path : RwLock :: new ( Arc :: new ( normalized_dirs) ) ,
36+ allowed_path : RwLock :: new ( Arc :: new ( normalized_dirs? ) ) ,
3537 } )
3638 }
3739
You can’t perform that action at this time.
0 commit comments