Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this 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 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?