Main Content

matlab.exception.JavaException class

Package:matlab.exception

Capture error information forJava异常

Description

Process information from amatlab.exception.JavaExceptionobject to handle Java®errors thrown by Java methods called from MATLAB®. This class is derived fromMException.

Creation

You do not construct amatlab.exception.JavaExceptionobject explicitly. MATLAB automatically constructs aJavaExceptionobject whenever Java throws an exception. TheJavaExceptionobject wraps the original Java exception.

Properties

expand all

Java exception object that caused the error, specified as ajava.lang.Throwableobject.

Examples

collapse all

Add amatlab.exception.JavaExceptionobject to atry-catchstatement.

tryjava.lang.Class.forName('myfunction');catche e.messageif(isa(e,'matlab.exception.JavaException')) ex = e.ExceptionObject; assert(isjava(ex)); ex.printStackTrace;endend

Version History

Introduced in R2012b