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 errors from convert function #175

Open
BenjaminRodenberg opened this issue Mar 13, 2023 · 1 comment
Open

Improve errors from convert function #175

BenjaminRodenberg opened this issue Mar 13, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@BenjaminRodenberg
Copy link
Member

The error return by the convert function is not helpful at the moment. I stumbled over this when I organized my participant names in an Enum

class ParticipantNames(Enum):
    MASS_LEFT = "Mass-Left"
    MASS_RIGHT = "Mass-Right"

One has to pass, for example, ParticipantNames.MASS_LEFT.value to the API. But I forgot the .values part, which led to an errors similar to

>>> precice.Interface(1,2,3,4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cyprecice/cyprecice.pyx", line 87, in cyprecice.Interface.__cinit__
  File "cyprecice/cyprecice.pyx", line 24, in cyprecice.convert
TypeError: Could not convert.

I think it would be good to tell the user which type was received from the API and which types are supported here. If I would have known that I provided a <enum 'ParticipantNames'> instead of a <class 'str'> this would have helped me a lot debugging.

@BenjaminRodenberg BenjaminRodenberg added the enhancement New feature or request label Mar 13, 2023
@BenjaminRodenberg
Copy link
Member Author

Another point where this problem shows up: If you provide the path to the configuration file not as a string, but as a pathlib.Path (which I think is actually the preferrable way of doing things). I now have to convert a pathlib.Path to a str before handing it over to the python API.

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

No branches or pull requests

1 participant