mirror of
https://github.com/wassname/ray.git
synced 2026-10-03 12:50:16 +08:00
[Java] Add java exception check in JNI (#6378)
This commit is contained in:
1 parent
e2ba8c1898
commit
7e9fddf3ed
5 files changed
+79
-8
No files matched your search
@@ -0,0 +1,19 @@
|
||||
package org.ray.runtime.util;
|
||||
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
// Required by JNI macro RAY_CHECK_JAVA_EXCEPTION
|
||||
public final class JniExceptionUtil {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(JniExceptionUtil.class);
|
||||
|
||||
public static String getStackTrace(String fileName, int lineNumber, String function,
|
||||
Throwable throwable) {
|
||||
LOGGER.error("An unexpected exception occurred while executing Java code from JNI ({}:{} {}).",
|
||||
fileName, lineNumber, function, throwable);
|
||||
// Return the exception in string form to JNI.
|
||||
return ExceptionUtils.getStackTrace(throwable);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user