Merge pull request #804 from AppFlowy-IO/fix-linting-and-add-message

chore: fix formating and add descriptive error message for parse failures
This commit is contained in:
Khor Shu Heng 2024-09-09 11:45:48 +08:00 committed by GitHub
commit b7521030b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -10,10 +10,12 @@ pub struct Config {
}
impl Config {
pub fn from_env() -> Result<Config, anyhow::Error> {
pub fn from_env() -> Result<Config, anyhow::Error> {
let cfg = Config {
host: get_or_default("ADMIN_FRONTEND_HOST", "0.0.0.0"),
port: get_or_default("ADMIN_FRONTEND_PORT", "3000").parse()?,
port: get_or_default("ADMIN_FRONTEND_PORT", "3000")
.parse()
.map_err(|e| anyhow::anyhow!("failed to parse ADMIN_FRONTEND_PORT as u16, err: {}", e))?,
redis_url: get_or_default("ADMIN_FRONTEND_REDIS_URL", "redis://localhost:6379"),
gotrue_url: get_or_default("ADMIN_FRONTEND_GOTRUE_URL", "http://localhost:9999"),
appflowy_cloud_url: get_or_default(