js4j 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/exceptions.js +15 -0
package/package.json
CHANGED
package/src/exceptions.js
CHANGED
|
@@ -33,6 +33,21 @@ class Js4JJavaError extends Js4JError {
|
|
|
33
33
|
this.javaException = javaException || null;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Fetch the human-readable Java exception message by calling getMessage()
|
|
38
|
+
* on the Java Throwable object. Falls back to the raw protocol payload
|
|
39
|
+
* (javaExceptionMessage) if the Java call fails or javaException is null.
|
|
40
|
+
* @returns {Promise<string>}
|
|
41
|
+
*/
|
|
42
|
+
async getJavaMessage() {
|
|
43
|
+
if (!this.javaException) return this.javaExceptionMessage || this.message;
|
|
44
|
+
try {
|
|
45
|
+
return await this.javaException.getMessage();
|
|
46
|
+
} catch (_) {
|
|
47
|
+
return this.javaExceptionMessage || this.message;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
36
51
|
toString() {
|
|
37
52
|
return `${this.name}: ${this.message}\n Java exception payload: ${this.javaExceptionMessage}`;
|
|
38
53
|
}
|