From 7e1716b02d9904b624c9a453d9d3166b0e07d7f6 Mon Sep 17 00:00:00 2001 From: gxcsoccer Date: Fri, 1 Jun 2018 15:49:33 +0800 Subject: [PATCH] fix: add cause prop to exception --- lib/exception.js | 4 ++++ test/exception.test.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/exception.js b/lib/exception.js index 83332b5..97062b8 100644 --- a/lib/exception.js +++ b/lib/exception.js @@ -57,6 +57,10 @@ module.exports = function toException(err, className) { '$class': '[java.lang.StackTraceElement', '$': stackTraceElements, }, + cause: { + '$class': 'java.lang.Throwable', + '$': null, + }, }, }; }; diff --git a/test/exception.test.js b/test/exception.test.js index d081f65..295aee0 100644 --- a/test/exception.test.js +++ b/test/exception.test.js @@ -17,6 +17,8 @@ describe('js error to java exception', function() { exception.$.stackTrace.$.forEach(function(ele) { assert.equal(ele.$class, 'java.lang.StackTraceElement'); }); + assert.equal(exception.$.cause.$class, 'java.lang.Throwable'); + assert(exception.$.cause.$ === null); // console.log(JSON.stringify(exception, null, 2)); }); @@ -29,6 +31,8 @@ describe('js error to java exception', function() { exception.$.stackTrace.$.forEach(function(ele) { assert.equal(ele.$class, 'java.lang.StackTraceElement'); }); + assert.equal(exception.$.cause.$class, 'java.lang.Throwable'); + assert(exception.$.cause.$ === null); // console.log(JSON.stringify(exception, null, 2)); }); });