summaryrefslogtreecommitdiff
path: root/pyvisa/errors.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyvisa/errors.py')
-rw-r--r--pyvisa/errors.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/pyvisa/errors.py b/pyvisa/errors.py
index 94ec7d1..b29534a 100644
--- a/pyvisa/errors.py
+++ b/pyvisa/errors.py
@@ -351,6 +351,9 @@ class Error(Exception):
def __init__(self, description):
super(Error, self).__init__(description)
+
+ def __eq__(self, other):
+ return self.__dict__ == other.__dict__
class VisaIOError(Error):
@@ -368,6 +371,9 @@ class VisaIOError(Error):
self.error_code = error_code
self.abbreviation = abbreviation
self.description = description
+
+ def __reduce__(self):
+ return (VisaIOError, (self.error_code,))
class VisaIOWarning(Warning):
@@ -384,6 +390,12 @@ class VisaIOWarning(Warning):
self.error_code = error_code
self.abbreviation = abbreviation
self.description = description
+
+ def __reduce__(self):
+ return (VisaIOWarning, (self.error_code,))
+
+ def __eq__(self, other):
+ return self.__dict__ == other.__dict__
class VisaTypeError(Error):
@@ -410,12 +422,22 @@ class UnknownHandler(Error):
def __init__(self, event_type, handler, user_handle):
super(UnknownHandler, self).__init__('%s, %s, %s' % (event_type, handler, user_handle))
+ self.event_type = event_type
+ self.handler = handler
+ self.user_handle = user_handle
+
+ def __reduce__(self):
+ return (UnknownHandler, (self.event_type, self.handler, self.user_handle))
class OSNotSupported(Error):
def __init__(self, os):
super(OSNotSupported, self).__init__(os + " is not yet supported by PyVISA")
+ self.os = os
+
+ def __reduce__(self):
+ return (OSNotSupported, (self.os,))
class InvalidBinaryFormat(Error):
@@ -424,6 +446,10 @@ class InvalidBinaryFormat(Error):
if description:
description = ": " + description
super(InvalidBinaryFormat, self).__init__("Unrecognized binary data format" + description)
+ self.description = description
+
+ def __reduce__(self):
+ return (InvalidBinaryFormat, (self.description,))
class InvalidSession(Error):
@@ -433,6 +459,9 @@ class InvalidSession(Error):
def __init__(self):
super(InvalidSession, self).__init__('Invalid session handle. The resource might be closed.')
+ def __reduce__(self):
+ return (InvalidSession, ())
+
class LibraryError(OSError, Error):