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 5
5
from collections .abc import Mapping , Sequence
6
6
from typing import Any , Literal
7
7
8
- from pygmt .exceptions import GMTInvalidInput
8
+ from pygmt .exceptions import GMTValueError
9
9
from pygmt .helpers .utils import is_nonstr_iter , sequence_join
10
10
11
11
@@ -116,12 +116,11 @@ def _to_string(
116
116
value = value [0 ]
117
117
case Mapping ():
118
118
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 (),
123
123
)
124
- raise GMTInvalidInput (msg )
125
124
value = mapping .get (value , value )
126
125
return f"{ prefix } { value } "
127
126
You can’t perform that action at this time.
0 commit comments