matlab.exception.JavaException class

Package: matlab.exception

Capture error information for Java exception

Description

Process information from a matlab.exception.JavaException object to handle Java® errors thrown by Java methods called from MATLAB®. This class is derived from MException.

Construction

e = matlab.exception.JavaException(msgID,errMsg,excObj) constructs instance e of matlab.exception.JavaException class.

You do not typically construct a matlab.exception.JavaException object explicitly. MATLAB automatically constructs a JavaException object whenever Java throws an exception. The JavaException object wraps the original Java exception.

Input Arguments

msgID

Message identifier

errMsg

Error message text

excObj

java.lang.Throwable object that caused the exception

Output Arguments

e

Instance of matlab.exception.JavaException class

Properties

ExceptionObject

Java exception object that caused the error

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects.

Examples

To display error information, use a matlab.exception.JavaException object in a try-catch statement.

try
    java.lang.Class.forName('myfunction');
catch e
    e.message
    if(isa(e,'matlab.exception.JavaException'))
        ex = e.ExceptionObject;
        assert(isJava(ex));
        ex.printStackTrace;
    end
end

Introduced in R2012b

Was this topic helpful?