Main Content

HandlePythonExceptions

MATLAB®catches exceptions thrown by Python®and converts them into amatlab.exception.PyExceptionobject, which is derived from theMExceptionclass. 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

See Also