HandlePythonExceptions
MATLAB®catches exceptions thrown by Python®and converts them into amatlab.exception.PyException
object, which is derived from theMException
class. For example:
trypy.list('x','y',1)catche e.messageif(isa(e,'matlab.exception.PyException')) e.ExceptionObjectendend
ans = Python Error: TypeError: list() takes at most 1 argument (3 given) ans = Python tuple with no properties. (, TypeError('list() takes at most 1 argument (3 given)',), None)
If MATLAB displays an error message of the following format, refer to your Python documentation for more information.
Python Error:Python class:message