Improve errors from `convert` function

Aperta Adatta ai principianti
#175 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
api

Direzione di ricerca

Inizia in cyprecice/cyprecice.pyx, nella funzione convert, alle righe 15-24, e riproduci il fallimento passando un membro di Enum quando è prevista una stringa. Aggiorna il comportamento dell’errore in modo che identifichi il tipo ricevuto e i tipi supportati, quindi verifica il messaggio risultante rispetto all’esempio Interface nell’issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

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.

Lingua principale
Cython
Stelle
30
Fork
19
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di precice/python-bindings

Tutte le issue di precice/python-bindings

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.