Skip to content

Release v2.6.0

Latest
Compare
Choose a tag to compare
@github-actions github-actions released this 21 Apr 10:05
ec3d822

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