Skip to content

Commit c2c81d7

Browse files
committed
Improve exception
1 parent 170d11b commit c2c81d7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pygmt/exceptions.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,22 +156,25 @@ def __init__(
156156
exclusive: Set[str] | None = None,
157157
reason: str | None = None,
158158
):
159-
msg = ""
159+
msg = []
160160
if required:
161-
msg = (
161+
msg.append(
162162
"Required parameter(s) are missing: "
163163
f"{', '.join(repr(par) for par in required)}."
164164
)
165+
165166
if require_any:
166-
msg = (
167+
msg.append(
167168
"At least one of the following parameters must be specified: "
168169
f"{', '.join(repr(par) for par in require_any)}."
169170
)
171+
170172
if exclusive:
171-
msg = (
173+
msg.append(
172174
"Mutually exclusive parameter(s) are specified: "
173175
f"{', '.join(repr(par) for par in exclusive)}."
174176
)
177+
175178
if reason:
176-
msg += f" {reason}"
177-
super().__init__(msg)
179+
msg.append(reason)
180+
super().__init__(" ".join(msg))

0 commit comments

Comments
 (0)