Skip to content

Commit 01b8267

Browse files
committed
Use GMTValueError
1 parent 3b8ae27 commit 01b8267

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

pygmt/alias.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from collections.abc import Mapping, Sequence
66
from typing import Any, Literal
77

8-
from pygmt.exceptions import GMTInvalidInput
8+
from pygmt.exceptions import GMTValueError
99
from 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

0 commit comments

Comments
 (0)