Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify unknown-extension error message #584

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/uwtools/utils/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from typing import IO, Any, Generator, Optional, Union

from uwtools.exceptions import UWError
from uwtools.logging import log
from uwtools.strings import FORMAT


Expand Down Expand Up @@ -52,10 +51,9 @@ def get_file_format(path: Path) -> str:
suffix = Path(path).suffix.replace(".", "")
try:
return FORMAT.formats()[suffix]
except KeyError as e:
except KeyError:
msg = f"Cannot deduce format of '{path}' from unknown extension '{suffix}'"
log.critical(msg)
raise UWError(msg) from e
raise UWError(msg) from None


def path_if_it_exists(path: str) -> str:
Expand Down
Loading