6
6
from typing import Literal
7
7
8
8
from pygmt ._typing import PathLike
9
- from pygmt .exceptions import GMTInvalidInput
9
+ from pygmt .exceptions import GMTInvalidInput , GMTValueError
10
10
11
11
12
12
def validate_output_table_type (
@@ -39,7 +39,7 @@ def validate_output_table_type(
39
39
>>> validate_output_table_type(output_type="invalid-type")
40
40
Traceback (most recent call last):
41
41
...
42
- pygmt.exceptions.GMTInvalidInput: Must specify 'output_type' either as 'file', ...
42
+ pygmt....GMTValueError: ...: 'invalid-type'. Expected one of: ...
43
43
>>> validate_output_table_type("file", outfile=None)
44
44
Traceback (most recent call last):
45
45
...
@@ -49,9 +49,13 @@ def validate_output_table_type(
49
49
... assert len(w) == 1
50
50
'file'
51
51
"""
52
- if output_type not in {"file" , "numpy" , "pandas" }:
53
- msg = "Must specify 'output_type' either as 'file', 'numpy', or 'pandas'."
54
- raise GMTInvalidInput (msg )
52
+ _valids = {"file" , "numpy" , "pandas" }
53
+ if output_type not in _valids :
54
+ raise GMTValueError (
55
+ output_type ,
56
+ description = "value for parameter 'output_type'" ,
57
+ choices = _valids ,
58
+ )
55
59
if output_type == "file" and outfile is None :
56
60
msg = "Must specify 'outfile' for output_type='file'."
57
61
raise GMTInvalidInput (msg )
0 commit comments