You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Most exceptions are about the GMT C library, and is only used once or a few times. But the GMTInvalidInput exception is used 87 times and will definitely increase as we wrap more modules.
The GMTInvalidInput exception is general and doesn't tell exactly what's happening. I haven't checked the source codes carefully, but I feel the exceptions can be grouped into a few categories:
A required parameter is not given
Given parameters have conflicts
A parameter is given with an incorrect type
A parameter is given with invalid values
Maybe more
I think we should have more accurate exceptions, e.g.,
GMTParameterError: for cases 1 and 2, maybe having more fine-grain exceptions like GMTRequiredParameterError/GMTConflictParameterError
GMTTypeError: for case 3, similar to the built-in TypeError
GMTValueError: for case 4, similar to the built-in ValueError.
The exception may even start with PYGMT, not GMT, since these are not directly related to GMT.
The text was updated successfully, but these errors were encountered:
seisman
changed the title
Add new exceptions for invalid inputs and deprecated GMTInvalidInput exception
Add new exceptions for invalid inputs and deprecate GMTInvalidInput exception
Dec 23, 2024
Currently, we have several exceptions defined in https://github.com/GenericMappingTools/pygmt/blob/main/pygmt/exceptions.py.
Below is a simple command to count how often each exception is raised in the codebase (The
tests
directory and theexceptions.py
file are excluded).the output is:
Most exceptions are about the GMT C library, and is only used once or a few times. But the
GMTInvalidInput
exception is used 87 times and will definitely increase as we wrap more modules.The
GMTInvalidInput
exception is general and doesn't tell exactly what's happening. I haven't checked the source codes carefully, but I feel the exceptions can be grouped into a few categories:I think we should have more accurate exceptions, e.g.,
GMTParameterError
: for cases 1 and 2, maybe having more fine-grain exceptions likeGMTRequiredParameterError
/GMTConflictParameterError
GMTTypeError
: for case 3, similar to the built-inTypeError
GMTValueError
: for case 4, similar to the built-inValueError
.The exception may even start with
PYGMT
, notGMT
, since these are not directly related to GMT.The text was updated successfully, but these errors were encountered: