DCOR-dev / DCOR-Aid

GUI for managing data on DCOR
https://dcor.mpl.mpg.de
GNU General Public License v3.0
1 stars 2 forks source link

Upload to non-existing circle produces confusing error message #64

Closed B-Hartmann closed 2 years ago

B-Hartmann commented 2 years ago

dcoraid 0.11.6 Windows 10 Python 3.9.0

When trying to upload data to an DCOR instance into a circle that actually does not exist yet on the server, the following error message is produced even though the api key used is correct:

Initializing.
Traceback (most recent call last):
  File "c:\users\bhartma\.environments\recover\lib\site-packages\dcoraid\cli.py", line 62, in upload_task
    uj = task.load_task(path_task,
  File "c:\users\bhartma\.environments\recover\lib\site-packages\dcoraid\upload\task.py", line 304, in load_task
    ddict = dataset_create(
  File "c:\users\bhartma\.environments\recover\lib\site-packages\dcoraid\api\dataset.py", line 62, in dataset_create
    data = api.post("package_create", dataset_dict)
  File "c:\users\bhartma\.environments\recover\lib\site-packages\dcoraid\api\ckan_api.py", line 317, in post
    resp = self.handle_response(req, api_call)
  File "c:\users\bhartma\.environments\recover\lib\site-packages\dcoraid\api\ckan_api.py", line 137, in handle_response
    raise APIAuthorizationError(msg)
dcoraid.api.errors.APIAuthorizationError: Authorization Error: message: Access denied: User dcoraid-39f3e not authorized to create packages (for 'package_create')

There should be a more descriptive error like "circle not found"

B-Hartmann commented 2 years ago

When the circle exists, but the collections one wants to add the data to, the following error message is shown:

Initializing.
Traceback (most recent call last):
  File "c:\users\bhartma\.environments\recover\lib\site-packages\dcoraid\cli.py", line 62, in upload_task
    uj = task.load_task(path_task,
  File "c:\users\bhartma\.environments\recover\lib\site-packages\dcoraid\upload\task.py", line 304, in load_task
    ddict = dataset_create(
  File "c:\users\bhartma\.environments\recover\lib\site-packages\dcoraid\api\dataset.py", line 62, in dataset_create
    data = api.post("package_create", dataset_dict)
  File "c:\users\bhartma\.environments\recover\lib\site-packages\dcoraid\api\ckan_api.py", line 317, in post
    resp = self.handle_response(req, api_call)
  File "c:\users\bhartma\.environments\recover\lib\site-packages\dcoraid\api\ckan_api.py", line 129, in handle_response
    raise APINotFoundError(msg)
dcoraid.api.errors.APINotFoundError: Not Found Error: message: Not found: Collection was not found. (for 'package_create')

This is a little more descriptive, but the Error that is thrown is not quite right. If possible, I would suggest something like "CircleNotFoundError" and "CollectionNotFoundError" to be raised in these situations.