Skip to content

Commit 947d3f4

Browse files
committed
Improve exception
1 parent 170d11b commit 947d3f4

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

pygmt/exceptions.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -156,22 +156,28 @@ def __init__(
156156
exclusive: Set[str] | None = None,
157157
reason: str | None = None,
158158
):
159-
msg = ""
159+
msg = []
160160
if required:
161-
msg = (
162-
"Required parameter(s) are missing: "
163-
f"{', '.join(repr(par) for par in required)}."
164-
)
161+
msg.append[
162+
(
163+
"Required parameter(s) are missing: "
164+
f"{', '.join(repr(par) for par in required)}."
165+
)
166+
]
165167
if require_any:
166-
msg = (
167-
"At least one of the following parameters must be specified: "
168-
f"{', '.join(repr(par) for par in require_any)}."
169-
)
168+
msg.append[
169+
(
170+
"At least one of the following parameters must be specified: "
171+
f"{', '.join(repr(par) for par in require_any)}."
172+
)
173+
]
170174
if exclusive:
171-
msg = (
172-
"Mutually exclusive parameter(s) are specified: "
173-
f"{', '.join(repr(par) for par in exclusive)}."
174-
)
175+
msg.append[
176+
(
177+
"Mutually exclusive parameter(s) are specified: "
178+
f"{', '.join(repr(par) for par in exclusive)}."
179+
)
180+
]
175181
if reason:
176-
msg += f" {reason}"
177-
super().__init__(msg)
182+
msg.append(reason)
183+
super().__init__(" ".join(msg))

0 commit comments

Comments
 (0)