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

Add more context to CLI error messages #531

Merged
merged 3 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Support for fetching catalog queryables [#477](https://github.com/stac-utils/pystac-client/pull/477)
- PySTAC Client specific warnings [#480](https://github.com/stac-utils/pystac-client/pull/480)
- Support for fetching and merging a selection of queryables [#511](https://github.com/stac-utils/pystac-client/pull/511)
- Better error messages for the CLI [#531](https://github.com/stac-utils/pystac-client/pull/531)

### Changed

Expand Down
15 changes: 12 additions & 3 deletions pystac_client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import warnings
from typing import Any, Dict, List, Optional

from pystac import STACTypeError

from .client import Client
from .conformance import ConformanceClasses
from .item_search import OPS
Expand Down Expand Up @@ -50,7 +52,7 @@ def search(
return 0

except Exception as e:
print(e)
print(f"ERROR: {e}")
return 1


Expand All @@ -64,8 +66,15 @@ def collections(client: Client, save: Optional[str] = None) -> int:
else:
print(json.dumps(collections_dicts))
return 0
except STACTypeError as e:
print(f"ERROR: {e}")
print(
f"The client at {client.self_href} is OK, but one or more of the "
"collections is invalid."
)
return 1
except Exception as e:
print(e)
print(f"ERROR: {e}")
return 1


Expand Down Expand Up @@ -329,7 +338,7 @@ def cli() -> int:
)

except Exception as e:
print(e, file=sys.stderr)
print(f"ERROR: {e}", file=sys.stderr)
return 1

if cmd == "search":
Expand Down