github MarkusJx/node-java-bridge v2.6.0
Release v2.6.0

6 months ago

Major changes

Errors thrown by the java process are now returned to the node process

Added a new property to each error, called cause which will contain the throwable from the Java process (if present):

import type { JavaError } from 'java-bridge';

try {
    // Call a method that throws an error
    someInstance.someMethodSync();
} catch (e: unknown) {
    const throwable = (e as JavaError).cause;
    throwable?.printStackTraceSync();
}

Added a config option called asyncJavaExceptionObjects to control whether the Java throwable should be returned from async contexts. This is required as enabling this option will cause the JavaScript stack trace to be lost. This option is disabled by default.

import { importClass, JavaError } from 'java-bridge';

const SomeClass = importClass('path.to.SomeClass', {
    asyncJavaExceptionObjects: true,
});

try {
    await SomeClass.someMethod();
} catch (e: unknown) {
    const throwable = (e as JavaError).cause;
    throwable?.printStackTraceSync();
}

What's Changed

  • feat(bridge): return java throwable to node process by @MarkusJx in #104
  • test(bridge): test import and method not found errors by @MarkusJx in #105

Full Changelog: v2.5.2...v2.6.0

Don't miss a new node-java-bridge release

NewReleases is sending notifications on new releases.