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

Improve error with missing dataset DOI #51

Closed
mih opened this issue Jun 17, 2022 · 3 comments
Closed

Improve error with missing dataset DOI #51

mih opened this issue Jun 17, 2022 · 3 comments

Comments

@mih
Copy link
Member

mih commented Jun 17, 2022

Current state:

% DATAVERSE_API_TOKEN=5367f732-36bd-46ed-975a-9eeaeb98fe74  git annex initremote dv1 encryption=none type=external externaltype=dataverse url=http://localhost:8080
initremote dv1 
git-annex: external special remote error: ERROR: GET HTTP 404 - http://localhost:8080/api/v1/datasets/:persistentId/?persistentId=. MSG: {"status":"ERROR","message":"Dataset with Persistent ID  not found."}
failed
initremote: 1 failed
@bpoldrack
Copy link
Member

Generally there are two ways of doing that in a special remote, assuming the problem is based on some exception (in that case a ConnectionError from the requests package.

  1. Have low level log for the actual exception and kinda decouple the user facing message:
try:
    do_the_request()
except requests.exceptions.ConnectionError as exc:
    # This will make sure the exception itself including its traceback, `__cause__`, `__context` is logged:
    ce =CapturedException(exc)
    # Form a proper user message.
    # Note: `CapturedException` provides a couple of properties to reuse (parts of) the original exception.
    self.message("Connection for purpose X failed due to {reason}".format(ce.message))
    sys.exit(1)  # Not sure if needed from the top of my head
  1. Include more generic information, which may be needed for debugging or really understanding the issue
try:
    do_the_request()
except RequestException as exc:
    # Note, that `RequestException` is more general
    raise ValueError("New message to provide context to the user") from exc

This will result in the an error message like New message to provide context to the user -- caused by -- ERROR: GET HTTP 404 - http://localhost:8080/api/v1/datasets/:persistentId/?persistentId=. ....

@jernsting
Copy link
Collaborator

Related to #48? I would opt for the second option

@jernsting
Copy link
Collaborator

Already done in #74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants