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

Error messages are ugly #14

Open
zmoog opened this issue Mar 7, 2023 · 3 comments
Open

Error messages are ugly #14

zmoog opened this issue Mar 7, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@zmoog
Copy link
Owner

zmoog commented Mar 7, 2023

$ tgl entries --project-id 178435728 group-by --field description --start-date 2023-02-28
Traceback (most recent call last):
  File "/Users/zmoog/code/projects/zmoog/toggl-track/venv/bin/tgl", line 33, in <module>
    sys.exit(load_entry_point('toggl-track', 'console_scripts', 'tgl')())
  File "/Users/zmoog/code/projects/zmoog/toggl-track/venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/zmoog/code/projects/zmoog/toggl-track/venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/zmoog/code/projects/zmoog/toggl-track/venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/zmoog/code/projects/zmoog/toggl-track/venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/zmoog/code/projects/zmoog/toggl-track/venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/zmoog/code/projects/zmoog/toggl-track/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/zmoog/code/projects/zmoog/toggl-track/venv/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/zmoog/code/projects/zmoog/toggl-track/toggl_track/cli.py", line 103, in group_by_entries
    client = TimeEntries.from_environment()
  File "/Users/zmoog/code/projects/zmoog/toggl-track/toggl_track/toggl.py", line 41, in from_environment
    raise Exception(
Exception: TOGGL_API_TOKEN environment variable not found. Please set it to your Toggl Track API token.
@zmoog
Copy link
Owner Author

zmoog commented Mar 7, 2023

When the TOGGL_API_TOKEN env variable is not defined CLI blows up.

@zmoog zmoog self-assigned this Mar 7, 2023
@zmoog zmoog added the bug Something isn't working label Mar 7, 2023
@zmoog
Copy link
Owner Author

zmoog commented Apr 3, 2023

Click has a section about error handling: https://click.palletsprojects.com/en/8.1.x/exceptions/

zmoog added a commit that referenced this issue Apr 4, 2023
Get the API token from the `--api-token` command-line option, with the
option of setting it from the TOGGL_API_TOKEN environment variable
using the `envvar` feature from Click.

Refs: #14
@zmoog
Copy link
Owner Author

zmoog commented Apr 4, 2023

Trying use a new --api-token option that leverages envvar feature from Click.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant