Search in sources :

Example 1 with PolyglotStatus

use of org.graalvm.polyglot.nativeapi.PolyglotNativeAPITypes.PolyglotStatus in project graal by oracle.

the class PolyglotNativeAPI method handleThrowable.

private static PolyglotStatus handleThrowable(Throwable t) {
    PolyglotStatus errorCode = t instanceof PolyglotNativeAPIError ? ((PolyglotNativeAPIError) t).getCode() : polyglot_generic_failure;
    String message = t.getMessage();
    PolyglotExtendedErrorInfo unmanagedErrorInfo = UnmanagedMemory.malloc(SizeOf.get(PolyglotExtendedErrorInfo.class));
    unmanagedErrorInfo.setErrorCode(errorCode.getCValue());
    CCharPointerHolder holder = CTypeConversion.toCString(message);
    CCharPointer value = holder.get();
    unmanagedErrorInfo.setErrorMessage(value);
    errorInfo.set(new ErrorInfoHolder(unmanagedErrorInfo, holder));
    return errorCode;
}
Also used : PolyglotExtendedErrorInfo(org.graalvm.polyglot.nativeapi.PolyglotNativeAPITypes.PolyglotExtendedErrorInfo) PolyglotStatus(org.graalvm.polyglot.nativeapi.PolyglotNativeAPITypes.PolyglotStatus) CCharPointerHolder(org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder) CCharPointer(org.graalvm.nativeimage.c.type.CCharPointer)

Aggregations

CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)1 CCharPointerHolder (org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder)1 PolyglotExtendedErrorInfo (org.graalvm.polyglot.nativeapi.PolyglotNativeAPITypes.PolyglotExtendedErrorInfo)1 PolyglotStatus (org.graalvm.polyglot.nativeapi.PolyglotNativeAPITypes.PolyglotStatus)1