I get "TypeError: exceptions should flow from BaseException", although I defined it

according to python docs, the exception comes from BaseExceptions, and I have to use it for custom exceptions. so I:

class VisaIOError(Exception): def __init__(self, error_code): abbreviation, description = _completion_and_error_messages[error_code] Error.__init__(self, abbreviation + ": " + description) self.error_code = error_code 

and

  raise(visa_exceptions.VisaIOError, status) 

but I get (trackback fragment):

  File "C:\Python32\Lib\site-packages\pyvisa\vpp43.py", line 400, in check_status raise(visa_exceptions.VisaIOError, status) TypeError: exceptions must derive from BaseException 

Note. I am converting code from python 27 to 32

+6
source share
1 answer

I need to do:

 raise visa_exceptions.VisaIOError(status) 
+4
source

Source: https://habr.com/ru/post/950115/


All Articles