@@ -41,7 +41,55 @@ class GMTCLibNoSessionError(GMTCLibError):
4141class GMTInvalidInput (GMTError ): # noqa: N818
4242 """
4343 Raised when the input of a function/method is invalid.
44+
45+ .. deprecated:: 0.13.0
46+ Use :class:`GMTParameterError` instead.
47+ """
48+
49+
50+ class GMTParameterError (GMTError ): # noqa: N818
4451 """
52+ Raised when parameters are missing or invalid.
53+
54+ Parameters
55+ ----------
56+ required
57+ Names of required parameters.
58+ require_any
59+ Names of parameters where at least one must be specified.
60+ exclusive
61+ Names of mutually exclusive parameters.
62+ reason
63+ Detailed reason why the parameters are invalid.
64+ """
65+
66+ def __init__ (
67+ self ,
68+ * ,
69+ required : set [str ] | None = None ,
70+ require_any : set [str ] | None = None ,
71+ exclusive : set [str ] | None = None ,
72+ reason : str | None = None ,
73+ ):
74+ msg = []
75+ if required :
76+ msg .append (
77+ "Required parameter(s) are missing: "
78+ f"{ ', ' .join (repr (par ) for par in required )} ."
79+ )
80+ if require_any :
81+ msg .append (
82+ "At least one of the following parameters must be specified: "
83+ f"{ ', ' .join (repr (par ) for par in require_any )} ."
84+ )
85+ if exclusive :
86+ msg .append (
87+ "Mutually exclusive parameter(s) are specified: "
88+ f"{ ', ' .join (repr (par ) for par in exclusive )} ."
89+ )
90+ if reason :
91+ msg .append (reason )
92+ super ().__init__ (" " .join (msg ))
4593
4694
4795class GMTVersionError (GMTError ):
0 commit comments