allows you to control how exceptions thrown in Java are handled in the Wolfram System.
$JavaExceptionHandler
allows you to control how exceptions thrown in Java are handled in the Wolfram System.
更多信息和选项
- To use $JavaExceptionHandler, you first need to load J/Link using Needs["JLink`"].
- The default behavior is for exceptions to appear as messages in the Wolfram System.
- If you want to override this behavior (for example to temporarily silence messages from exceptions), assign a value to $JavaExceptionHandler.
- The value of $JavaExceptionHandler is treated as a function that will be passed three arguments: the symbol associated with the message (this will currently always be the symbol Java), the message tag (this will be the string "excptn" for a typical exception or "pexcptn" for an exception generated by a manual return method where the exception occurs after the method has manually sent its result back to the Wolfram Language), and the descriptive string of text associated with the message.
- You will typically set $JavaExceptionHandler within a Block so that its effect will be limited to a precisely defined segment of code, as in the following example that silences messages: Block[{$JavaExceptionHandler=Null&},obj@method[]].
- You can use GetJavaException within your handler function to obtain the actual Java exception object that was thrown.
文本
Wolfram Research (2007),$JavaExceptionHandler,Wolfram 语言函数,https://reference.wolfram.com/language/JLink/ref/$JavaExceptionHandler.html.
CMS
Wolfram 语言. 2007. "$JavaExceptionHandler." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/JLink/ref/$JavaExceptionHandler.html.
APA
Wolfram 语言. (2007). $JavaExceptionHandler. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/JLink/ref/$JavaExceptionHandler.html 年
BibTeX
@misc{reference.wolfram_2025_$javaexceptionhandler, author="Wolfram Research", title="{$JavaExceptionHandler}", year="2007", howpublished="\url{https://reference.wolfram.com/language/JLink/ref/$JavaExceptionHandler.html}", note=[Accessed: 06-November-2025]}
BibLaTeX
@online{reference.wolfram_2025_$javaexceptionhandler, organization={Wolfram Research}, title={$JavaExceptionHandler}, year={2007}, url={https://reference.wolfram.com/language/JLink/ref/$JavaExceptionHandler.html}, note=[Accessed: 06-November-2025]}