Skip to content

Commit

Permalink
Unwind extra error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed Jan 3, 2025
1 parent d91fa3e commit d76bc1a
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions optimade/server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,16 +498,11 @@ def align_mongo_uri_and_mongo_database(self) -> "ServerConfig":
or self.mongo_uri.startswith("mongodb+srv://")
):
self.mongo_uri = f"mongodb://{self.mongo_uri}"
try:
uri: dict[str, Any] = pymongo.uri_parser.parse_uri(
self.mongo_uri, warn=True
)
if uri.get("database"):
self.mongo_database = uri["database"]
except pymongo.errors.InvalidURI as error_msg:
warnings.warn(
f"The uri {self.mongo_uri} may be invalid.\n{error_msg}"
)
uri: dict[str, Any] = pymongo.uri_parser.parse_uri(
self.mongo_uri, warn=True
)
if uri.get("database"):
self.mongo_database = uri["database"]

return self

Expand Down

0 comments on commit d76bc1a

Please sign in to comment.