JLink`
JLink`

$JavaExceptionHandler

$JavaExceptionHandler

allows you to control how exceptions thrown in Java are handled in the Wolfram System.

Details and Options

  • 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 Language function, https://reference.wolfram.com/language/JLink/ref/$JavaExceptionHandler.html.

Text

Wolfram Research (2007), $JavaExceptionHandler, Wolfram Language function, https://reference.wolfram.com/language/JLink/ref/$JavaExceptionHandler.html.

CMS

Wolfram Language. 2007. "$JavaExceptionHandler." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/JLink/ref/$JavaExceptionHandler.html.

APA

Wolfram Language. (2007). $JavaExceptionHandler. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/JLink/ref/$JavaExceptionHandler.html

BibTeX

@misc{reference.wolfram_2024_$javaexceptionhandler, author="Wolfram Research", title="{$JavaExceptionHandler}", year="2007", howpublished="\url{https://reference.wolfram.com/language/JLink/ref/$JavaExceptionHandler.html}", note=[Accessed: 22-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_$javaexceptionhandler, organization={Wolfram Research}, title={$JavaExceptionHandler}, year={2007}, url={https://reference.wolfram.com/language/JLink/ref/$JavaExceptionHandler.html}, note=[Accessed: 22-December-2024 ]}