File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 55from collections .abc import Mapping , Sequence
66from typing import Any , Literal
77
8- from pygmt .exceptions import GMTInvalidInput
8+ from pygmt .exceptions import GMTValueError
99from pygmt .helpers .utils import is_nonstr_iter , sequence_join
1010
1111
@@ -116,12 +116,11 @@ def _to_string(
116116 value = value [0 ]
117117 case Mapping ():
118118 if value not in mapping and value not in mapping .values ():
119- _name = f"Parameter { name !r } : " if name else ""
120- msg = (
121- f" { _name } Invalid value: { value !r} . "
122- f"Valid values are: { ', ' . join ( mapping ) } ."
119+ raise GMTValueError (
120+ value ,
121+ description = " value for parameter {name !r}" if name else "value" ,
122+ choices = mapping . keys (),
123123 )
124- raise GMTInvalidInput (msg )
125124 value = mapping .get (value , value )
126125 return f"{ prefix } { value } "
127126
You can’t perform that action at this time.
0 commit comments