Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

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

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

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?