handle remote exception (#12694)

* add cause property to exception in callFunction

* update exceptionToMeta function

* add sender argument
* and cause property to return value

* update exception convert in metaToValue function

* add from and cause properties to the exception error

* unit test for remote exception
This commit is contained in:
Tatsuya Hiroishi 2018-04-24 21:40:19 +09:00 committed by Shelley Vohr
parent 2579071b98
commit 9c65abd746
4 changed files with 54 additions and 17 deletions

View file

@ -370,4 +370,26 @@ describe('remote module', () => {
assert.equal(method(), 'method')
})
})
describe('remote exception', () => {
const throwFunction = remote.require(path.join(fixtures, 'module', 'exception.js'))
it('throws errors from the main process', () => {
assert.throws(() => {
throwFunction()
})
})
it('throws custom errors from the main process', () => {
let err = new Error('error')
err.cause = new Error('cause')
err.prop = 'error prop'
try {
throwFunction(err)
} catch (error) {
assert.ok(error.from)
assert.deepEqual(error.cause, err)
}
})
})
})