mirror of
https://github.com/wassname/ray.git
synced 2026-07-05 03:21:00 +08:00
[Java] Add java exception check in JNI (#6378)
This commit is contained in:
@@ -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