Documentation Center

  • Trial Software
  • Product Updates

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 from 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.

Input Arguments

msgID

message identifier

errMsg

error message string

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.

Tips

  • 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.

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects in the MATLAB documentation.

Examples

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

More About

Was this topic helpful?