66from typing import Literal
77
88from pygmt ._typing import PathLike
9- from pygmt .exceptions import GMTInvalidInput
9+ from pygmt .exceptions import GMTInvalidInput , GMTValueError
1010
1111
1212def validate_output_table_type (
@@ -39,7 +39,7 @@ def validate_output_table_type(
3939 >>> validate_output_table_type(output_type="invalid-type")
4040 Traceback (most recent call last):
4141 ...
42- pygmt.exceptions.GMTInvalidInput: Must specify 'output_type' either as 'file', ...
42+ pygmt....GMTValueError: ...: 'invalid-type'. Expected one of: ...
4343 >>> validate_output_table_type("file", outfile=None)
4444 Traceback (most recent call last):
4545 ...
@@ -49,9 +49,13 @@ def validate_output_table_type(
4949 ... assert len(w) == 1
5050 'file'
5151 """
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+ )
5559 if output_type == "file" and outfile is None :
5660 msg = "Must specify 'outfile' for output_type='file'."
5761 raise GMTInvalidInput (msg )
0 commit comments