Skip to content

Commit a9b0363

Browse files
committed
Add the GMTTypeError exception
1 parent 89044b8 commit a9b0363

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pygmt/exceptions.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,18 @@ def __init__(
115115
if reason:
116116
msg += f" {reason}"
117117
super().__init__(msg)
118+
119+
120+
class GMTTypeError(GMTError, TypeError):
121+
"""
122+
Raised when an invalid type is passed to a function/method.
123+
124+
This exception is used to indicate that the type of an argument does not match
125+
the expected type.
126+
"""
127+
128+
def __init__(self, dtype: object, /, reason: str | None = None):
129+
msg = f"Unrecognized data type: {dtype!r}."
130+
if reason:
131+
msg += f" {reason}"
132+
super().__init__(msg)

0 commit comments

Comments
 (0)