Skip to content

fix: return InvalidConfig error instead of panicking for invalid directories#80

Merged
hashemix merged 2 commits intomainfrom
fix/issue-71-improve-error-handling-avoid-panic
Mar 15, 2026
Merged

fix: return InvalidConfig error instead of panicking for invalid directories#80
hashemix merged 2 commits intomainfrom
fix/issue-71-improve-error-handling-avoid-panic

Conversation

@hashemix
Copy link
Copy Markdown
Member

📌 Summary

Refactors directory validation in FileSystemService::try_new to return a proper InvalidConfig error instead of panicking when an allowed directory is invalid.

🔍 Related Issues

✨ Changes Made

  • Add InvalidConfig(String) variant to ServiceError enum
  • Replace .map_while() with .map() and proper error handling
  • Convert panic to ServiceError::InvalidConfig with descriptive message

🛠️ Testing Steps

Test with an invalid directory path in the server configuration and verify a proper error is returned instead of a panic:

cargo run /invalid-dir

@hashemix hashemix changed the title feat: return InvalidConfig error instead of panicking for invalid directories fix: return InvalidConfig error instead of panicking for invalid directories Mar 15, 2026
@hashemix hashemix merged commit fcb5552 into main Mar 15, 2026
10 checks passed
@hashemix hashemix mentioned this pull request Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant