Call of a jar-file (compiled with matlab), throw complete stack (of matlab errors) back to java
2 次查看(过去 30 天)
显示 更早的评论
Hallo,
I'm trying to integrate a compiled matlab-programm (as a jar-file) into a java-environment.
1) Is it possible to get a complete stack-trace back to original calling jar-file out of matlab? (Line numbers, functions, ...)
Up to now, it seems that I've to use something like that:
try
catch
msgText = getReport(ME,'extended','hyperlinks','off');
msgText2 = regexprep(msgText,'\s+',' ');
baseException = MException(msgID,msgText2);
throw(baseException);
end
2) Is it possible that the all exceptions are formated in that way, without defining a try-catch-block around the whole function?
Thank you
0 个评论
采纳的回答
Sanjana Ramakrishnan
2017-1-19
1.The message text and stack information would be available in an 'MWException' class in Java. You can use a try/catch on the java side to capture the same. Refer the following example:
try{
foo.Class1 c = new foo.Class1();
c.foo();
}
catch(MWException e){
System.out.println(e.getMessage());
e.printStackTrace();
}
2. Since MWExceptions don’t include the message id, you can write a small function to capture the desired information rather than include it in each try catch.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Java Package Integration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!